diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-20 22:15:44 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-20 22:15:44 +0000 |
commit | eaacff4826f730d3c62b49063ad7955d6f53e4af (patch) | |
tree | 4258dfc5cb56b3ebd9bb91ad65cb581c0b422864 /clang/test/Analysis/retain-release.m | |
parent | 6bae2a57d5b7ef62ca950e62da2eaf01aeebfef9 (diff) | |
download | bcm5719-llvm-eaacff4826f730d3c62b49063ad7955d6f53e4af.tar.gz bcm5719-llvm-eaacff4826f730d3c62b49063ad7955d6f53e4af.zip |
[analyzer] More tests for "release and stop tracking".
Under GC, a release message is ignored, so "release and stop tracking" just
becomes "stop tracking". But CFRelease is still honored. This is the main
difference between ns_consumed and cf_consumed.
llvm-svn: 162234
Diffstat (limited to 'clang/test/Analysis/retain-release.m')
-rw-r--r-- | clang/test/Analysis/retain-release.m | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/Analysis/retain-release.m b/clang/test/Analysis/retain-release.m index efd05329455..da1477bb588 100644 --- a/clang/test/Analysis/retain-release.m +++ b/clang/test/Analysis/retain-release.m @@ -1748,7 +1748,7 @@ extern id NSApp; @end //===----------------------------------------------------------------------===// // Test returning allocated memory in a struct. -// +// // We currently don't have a general way to track pointers that "escape". // Here we test that RetainCountChecker doesn't get excited about returning // allocated CF objects in struct fields. @@ -1856,7 +1856,10 @@ id makeCollectableNonLeak() { return [objCObject autorelease]; // +0 } + void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); +void CFConsumeAndStopTracking(CFTypeRef CF_CONSUMED obj, void (^callback)(void)); + void testConsumeAndStopTracking() { id retained = [@[] retain]; // +1 consumeAndStopTracking(retained, ^{}); // no-warning @@ -1869,3 +1872,16 @@ void testConsumeAndStopTracking() { id unretained = @[]; // +0 consumeAndStopTracking(unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} } + +void testCFConsumeAndStopTracking() { + id retained = [@[] retain]; // +1 + CFConsumeAndStopTracking((CFTypeRef)retained, ^{}); // no-warning + + id doubleRetained = [[@[] retain] retain]; // +2 + CFConsumeAndStopTracking((CFTypeRef)doubleRetained, ^{ + [doubleRetained release]; + }); // no-warning + + id unretained = @[]; // +0 + CFConsumeAndStopTracking((CFTypeRef)unretained, ^{}); // expected-warning {{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} |