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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74098 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2009-06-24 19:04:37 +00:00
Родитель 7d277e25e0
Коммит 6fe1ef2bbb
3 изменённых файлов: 13 добавлений и 15 удалений

Просмотреть файл

@ -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>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

Двоичные данные
www/analyzer/images/example_cf_returns_retained.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 46 KiB

Двоичные данные
www/analyzer/images/example_cf_returns_retained_gc.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 46 KiB