[cfe-commits] r66487 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/retain-release.m

Ted Kremenek kremenek at apple.com
Mon Mar 9 15:46:49 PDT 2009


Author: kremenek
Date: Mon Mar  9 17:46:49 2009
New Revision: 66487

URL: http://llvm.org/viewvc/llvm-project?rev=66487&view=rev
Log:
retain/release checker: Allow allocations to fail by returning nil.

Modified:
    cfe/trunk/lib/Analysis/CFRefCount.cpp
    cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=66487&r1=66486&r2=66487&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Mon Mar  9 17:46:49 2009
@@ -1840,12 +1840,16 @@
         state.set<RefBindings>(Sym, RefVal::makeOwned(RE.getObjKind(), RetT));      
       state = state.BindExpr(Ex, loc::SymbolVal(Sym), false);
 
-      // FIXME: Add a flag to the checker where allocations are allowed to fail.      
+
+      // FIXME: Add a flag to the checker where allocations are assumed to
+      // *not fail.
+#if 0
       if (RE.getKind() == RetEffect::OwnedAllocatedSymbol) {
         bool isFeasible;
         state = state.Assume(loc::SymbolVal(Sym), true, isFeasible);
         assert(isFeasible && "Cannot assume fresh symbol is non-null.");        
       }
+#endif
       
       break;
     }

Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=66487&r1=66486&r2=66487&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Mon Mar  9 17:46:49 2009
@@ -196,9 +196,8 @@
 CFDateRef f9() {
   CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent());
   int *p = 0;
-  // test that the checker assumes that CFDateCreate returns a non-null
-  // pointer
-  if (!date) *p = 1; // no-warning
+  // When allocations fail, CFDateCreate can return null.
+  if (!date) *p = 1; // expected-warning{{null}}
   return date;
 }
 
@@ -316,7 +315,7 @@
     kindC = [kind UTF8String];
   if(name)
     nameC = [name UTF8String];
-  if(!isFoo(kindC[0])) // no-warning
+  if(!isFoo(kindC[0])) // expected-warning{{null}}
     return;
   if(!isFoo(nameC[0])) // no-warning
     return;





More information about the cfe-commits mailing list