]> granicus.if.org Git - clang/commitdiff
Fix regression reported in <rdar://problem/6866843>. The analyzer should extend...
authorTed Kremenek <kremenek@apple.com>
Mon, 11 May 2009 18:30:24 +0000 (18:30 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 11 May 2009 18:30:24 +0000 (18:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71452 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp
test/Analysis/retain-release.m

index ebc4dcc6ff5df9cfb9699ecbcedeff4e6f31939f..29a28c1a19992850f7e990aa5d93987fb06a7a23 100644 (file)
@@ -752,8 +752,8 @@ public:
                              : 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();
index 1c0bb964b2de5bedf05cf283131be457807cc747..f4c2d25054142b942d1f38c892402a1a14af886c 100644 (file)
@@ -476,7 +476,7 @@ void rdar6704930(unsigned char *s, unsigned int length) {
 // <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 @@ void rdar6704930(unsigned char *s, unsigned int length) {
 // <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}}
@@ -511,6 +511,23 @@ int rdar_6257780() {
   return 0;
 }
 
+//===----------------------------------------------------------------------===//
+// <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.
 //===----------------------------------------------------------------------===//