Replace 'clang --analyze' example for attribute cf_returns_retained with screenshots.

llvm-svn: 74098
This commit is contained in:
Ted Kremenek 2009-06-24 19:04:37 +00:00
parent 70413126b6
commit 550e701cf5
3 changed files with 13 additions and 15 deletions

View File

@ -259,23 +259,21 @@ CFDateRef returnsRetainedCFDate() {
return (NSDate*) returnsRetainedCFDate(); // Report a leak when using GC.
}
@end
<span class="command">$ clang --analyze test.m</span>
test.m:28:20: warning: Potential leak of an object allocated on line 28
return (NSDate*) returnsRetainedCFDate(); // Always report a leak.
^
1 diagnostic generated.
<span class="command">$ clang --analyze test.m <span class="code_highlight">-fobjc-gc-only</span></span>
test.m:28:20: warning: Potential leak (when using garbage collection) of an object allocated on line 28
return (NSDate*) returnsRetainedCFDate(); // Always report a leak.
^
test.m:32:20: warning: Potential leak (when using garbage collection) of an object allocated on line 32
return (NSDate*) returnsRetainedCFDate(); // Report a leak when using GC.
^
2 diagnostics generated.
</pre>
<p>Running <tt>scan-build</tt> on this example produces the following output:</p>
<img src="images/example_cf_returns_retained.png">
</p>When the above code is compiled using Objective-C garbage collection (i.e.,
code is compiled with the flag <tt>-fobjc-gc</tt> or <tt>-fobjc-gc-only</tt>),
<tt>scan-build</tt> produces both the above error (with slightly different text
to indicate the code uses garbage collection) as well as the following warning,
which indicates a leak that occurs <em>only</em> when using garbage
collection:</p>
<img src="images/example_cf_returns_retained_gc.png">
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<h2 id="custom_assertions">Custom Assertion Handlers</h2>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB