diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-05-11 18:30:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-05-11 18:30:24 +0000 |
commit | ebd5a2dc1a3743fed9157379d89e5eb26293c9d6 (patch) | |
tree | 18ca9e0ff102a186c625de4be5d611761b27d9a3 | |
parent | d6a9907ceff2c52738a72e38b6a04ab44ce1173f (diff) |
Fix regression reported in <rdar://problem/6866843>. The analyzer should extend the lifetime of an object stored to a container.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71452 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 4 | ||||
-rw-r--r-- | test/Analysis/retain-release.m | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index ebc4dcc6ff..29a28c1a19 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -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(); diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 1c0bb964b2..f4c2d25054 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -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}} @@ -512,6 +512,23 @@ int rdar_6257780() { } //===----------------------------------------------------------------------===// +// <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. //===----------------------------------------------------------------------===// |