diff options
author | Jordan Rose <jordan_rose@apple.com> | 2012-08-20 20:01:15 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2012-08-20 20:01:15 +0000 |
commit | f902d097bf7ee24d27e34f351e7c3d66a9db538e (patch) | |
tree | 45c54ae171336999d165678b166dbdb45217d6b1 | |
parent | d7403a70176a50b8f71cb4e2e18ac6ed49fe357e (diff) |
[analyzer] Add a test for "release and stop tracking" behavior.
This is used to handle functions and methods that consume an argument
(annotated with the ns_consumed or cf_consumed attribute), but then the
argument's retain count may be further modified in a callback. We want
to warn about over-releasing, but we can't really track the object afterwards.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162221 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/Analysis/retain-release.m | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index ba492b7b19..efd0532945 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1855,3 +1855,17 @@ id makeCollectableNonLeak() { [objCObject release]; // +1 return [objCObject autorelease]; // +0 } + +void consumeAndStopTracking(id NS_CONSUMED obj, void (^callback)(void)); +void testConsumeAndStopTracking() { + id retained = [@[] retain]; // +1 + consumeAndStopTracking(retained, ^{}); // no-warning + + id doubleRetained = [[@[] retain] retain]; // +2 + consumeAndStopTracking(doubleRetained, ^{ + [doubleRetained release]; + }); // no-warning + + 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}} +} |