[llvm-branch-commits] [cfe-branch] r71342 - in /cfe/branches/Apple/Dib: lib/Analysis/CFRefCount.cpp test/Analysis/retain-release.m

Mike Stump mrs at apple.com
Fri May 8 23:23:09 PDT 2009


Author: mrs
Date: Sat May  9 01:23:09 2009
New Revision: 71342

URL: http://llvm.org/viewvc/llvm-project?rev=71342&view=rev
Log:
Merge in 71307:

It lives!  The retain/release checker now tracks objects that are sent
'autorelease'.

Modified:
    cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
    cfe/branches/Apple/Dib/test/Analysis/retain-release.m

Modified: cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp?rev=71342&r1=71341&r2=71342&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp Sat May  9 01:23:09 2009
@@ -175,8 +175,7 @@
   ExplodedNode<GRState> *MakeNode(const GRState *state,
                                   ExplodedNode<GRState> *Pred) {
     if (SNB)
-      return SNB->generateNode(PostStmt(S, tag), state,
-                               Pred);
+      return SNB->generateNode(PostStmt(S, tag), state, Pred);
     
     assert(ENB);
     return ENB->generateNode(state, Pred);
@@ -3111,6 +3110,7 @@
       // Update the autorelease counts.
       state = SendAutorelease(state, ARCountFactory, sym);
       V = V.autorelease();
+      break;
 
     case StopTracking:
       return state.remove<RefBindings>(sym);
@@ -3245,7 +3245,7 @@
     return Pred;
   
   // Generate an intermediate node representing the leak point.
-  ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);  
+  ExplodedNode<GRState> *N = Builder.MakeNode(state, Pred);
   
   if (N) {
     for (llvm::SmallVectorImpl<SymbolRef>::iterator
@@ -3354,7 +3354,8 @@
   Builder.BuildSinks = true;
   GRExprEngine::NodeTy* N  = Builder.MakeNode(Dst, NodeExpr, Pred, St);
   
-  if (!N) return;
+  if (!N)
+    return;
   
   CFRefBug *BT = 0;
   

Modified: cfe/branches/Apple/Dib/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/retain-release.m?rev=71342&r1=71341&r2=71342&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/retain-release.m (original)
+++ cfe/branches/Apple/Dib/test/Analysis/retain-release.m Sat May  9 01:23:09 2009
@@ -284,10 +284,32 @@
 }
 
 void f13_autorelease() {
-  CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+  CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
   [(id) A autorelease]; // no-warning
 }
 
+void f13_autorelease_b() {
+  CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+  [(id) A autorelease];
+  [(id) A autorelease]; // expected-warning{{Object will be sent more -release messages from its containing autorelease pools than it has retain counts}}
+}
+
+CFMutableArrayRef f13_autorelease_c() {
+  CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+  [(id) A autorelease];
+  [(id) A autorelease]; 
+  return A; // expected-warning{{Object will be sent more -release messages from its containing autorelease pools than it has retain counts}}
+}
+
+CFMutableArrayRef f13_autorelease_d() {
+  CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks);
+  [(id) A autorelease];
+  [(id) A autorelease]; 
+  CFMutableArrayRef B = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Object will be sent more -release messages}}
+  CFRelease(B); // no-warning
+}
+
+
 // This case exercises the logic where the leak site is the same as the allocation site.
 void f14_leakimmediately() {
   CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}





More information about the llvm-branch-commits mailing list