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

Mike Stump mrs at apple.com
Wed May 13 08:36:32 PDT 2009


Author: mrs
Date: Wed May 13 10:36:27 2009
New Revision: 71669

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

Fix crasher in CFRefCount.cpp reported by Nikita Zhuk due to recently added autorelease tracking.

Modified:
    cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp
    cfe/branches/Apple/Dib/test/Analysis/NSString.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=71669&r1=71668&r2=71669&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/CFRefCount.cpp Wed May 13 10:36:27 2009
@@ -2154,6 +2154,9 @@
                                             const ExplodedNode<GRState>* PrevN,
                                             BugReporterContext& BRC) {
   
+  if (!isa<PostStmt>(N->getLocation()))
+    return NULL;
+  
   // Check if the type state has changed.
   GRStateManager &StMgr = BRC.getStateManager();
   GRStateRef PrevSt(PrevN->getState(), StMgr);
@@ -2373,8 +2376,8 @@
   
   if (os.str().empty())
     return 0; // We have nothing to say!
-  
-  Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();    
+
+  Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
   PathDiagnosticLocation Pos(S, BRC.getSourceManager());
   PathDiagnosticPiece* P = new PathDiagnosticEventPiece(Pos, os.str());
   

Modified: cfe/branches/Apple/Dib/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/NSString.m?rev=71669&r1=71668&r2=71669&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/NSString.m (original)
+++ cfe/branches/Apple/Dib/test/Analysis/NSString.m Wed May 13 10:36:27 2009
@@ -183,6 +183,33 @@
   NSString *str = [[NSString alloc] init];
   return [str autorelease]; // no-warning
 }
+- (void)m1
+{
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ [s retain];
+ [s autorelease];
+}
+- (void)m2
+{
+ NSString *s = [[[NSString alloc] init] autorelease]; // expected-warning{{leak}}
+ [s retain];
+}
+- (void)m3
+{
+ NSString *s = [[[NSString alloc] init] autorelease];
+ [s retain];
+ [s autorelease];
+}
+- (void)m4
+{
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ [s retain];
+}
+- (void)m5
+{
+ NSString *s = [[NSString alloc] init];
+ [s autorelease];
+}
 @end
 
 @interface C1 : NSObject {}
@@ -298,8 +325,6 @@
   return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // expected-warning{{leak}}
 }
 
-
-
 // Test @synchronized
 void test_synchronized(id x) {
   @synchronized(x) {
@@ -307,4 +332,4 @@
   }
 }
 
-// Test return from method starting with 'new' or 'copy'
+





More information about the llvm-branch-commits mailing list