[cfe-commits] r162221 - /cfe/trunk/test/Analysis/retain-release.m
Anna Zaks
ganna at apple.com
Mon Aug 20 14:01:18 PDT 2012
Both DecRefAndStopTracking and DecRefMsgAndStopTracking were not covered by tests. This probably tests only one of them, right?
Anna.
On Aug 20, 2012, at 1:01 PM, Jordan Rose wrote:
> Author: jrose
> Date: Mon Aug 20 15:01:15 2012
> New Revision: 162221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=162221&view=rev
> Log:
> [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.
>
> Modified:
> cfe/trunk/test/Analysis/retain-release.m
>
> Modified: cfe/trunk/test/Analysis/retain-release.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=162221&r1=162220&r2=162221&view=diff
> ==============================================================================
> --- cfe/trunk/test/Analysis/retain-release.m (original)
> +++ cfe/trunk/test/Analysis/retain-release.m Mon Aug 20 15:01:15 2012
> @@ -1855,3 +1855,17 @@
> [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}}
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120820/58bc9a16/attachment.html>
More information about the cfe-commits
mailing list