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

Ted Kremenek kremenek at apple.com
Mon May 11 11:30:27 PDT 2009


Author: kremenek
Date: Mon May 11 13:30:24 2009
New Revision: 71452

URL: http://llvm.org/viewvc/llvm-project?rev=71452&view=rev
Log:
Fix regression reported in <rdar://problem/6866843>.  The analyzer should extend the lifetime of an object stored to a container.

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=71452&r1=71451&r2=71452&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Mon May 11 13:30:24 2009
@@ -752,8 +752,8 @@
                              : RetEffect::MakeOwned(RetEffect::ObjC, true)),
      DefaultSummary(AF.GetEmptyMap() /* per-argument effects (none) */,
                     RetEffect::MakeNoRet() /* return effect */,
-                    DoNothing /* receiver effect */,
-                    MayEscape /* default argument effect */),
+                    MayEscape, /* default argument effect */
+                    DoNothing /* receiver effect */),
      StopSummary(0) {
 
     InitializeClassMethodSummaries();

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

==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Mon May 11 13:30:24 2009
@@ -476,7 +476,7 @@
 // <rdar://problem/6833332>
 // One build of the analyzer accidentally stopped tracking the allocated
 // object after the 'retain'.
-//===----------------------------------------------------------------------===//                             
+//===----------------------------------------------------------------------===//
 
 @interface rdar_6833332 : NSObject <NSApplicationDelegate> {
     NSWindow *window;
@@ -503,7 +503,7 @@
 // <rdar://problem/6257780> clang checker fails to catch use-after-release
 //===----------------------------------------------------------------------===//
                                  
-int rdar_6257780() {
+int rdar_6257780_Case1() {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
   NSArray *array = [NSArray array];
   [array release]; // expected-warning{{Incorrect decrement of the reference count of an object is not owned at this point by the caller}}
@@ -512,6 +512,23 @@
 }
 
 //===----------------------------------------------------------------------===//
+// <rdar://problem/6866843> Checker should understand new/setObject:/release constructs
+//===----------------------------------------------------------------------===//
+
+void rdar_6866843() {
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] init];
+ NSArray* array = [[NSArray alloc] init];
+ [dictionary setObject:array forKey:@"key"];
+ [array release];
+ // Using 'array' here should be fine
+ NSLog(@"array = %@\n", array); // no-warning
+ // Now the array is released
+ [dictionary release];
+ [pool drain];
+}
+
+//===----------------------------------------------------------------------===//
 // Tests of ownership attributes.
 //===----------------------------------------------------------------------===//
 





More information about the cfe-commits mailing list