From: Ted Kremenek
Date: Wed, 24 Jun 2009 19:04:37 +0000 (+0000)
Subject: Replace 'clang --analyze' example for attribute cf_returns_retained with screenshots.
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6fe1ef2bbbf2ccf42c935e2a8b857fcfffdb1374;p=clang
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
---
diff --git a/www/analyzer/annotations.html b/www/analyzer/annotations.html
index f76dbee12a..7d509ed5db 100644
--- a/www/analyzer/annotations.html
+++ b/www/analyzer/annotations.html
@@ -259,22 +259,20 @@ CFDateRef returnsRetainedCFDate() {
return (NSDate*) returnsRetainedCFDate(); // Report a leak when using GC.
}
@end
+
-$ clang --analyze test.m
-test.m:28:20: warning: Potential leak of an object allocated on line 28
- return (NSDate*) returnsRetainedCFDate(); // Always report a leak.
- ^
-1 diagnostic generated.
+Running scan-build on this example produces the following output:
-$ clang --analyze test.m -fobjc-gc-only
-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.
-
+
+
+
When the above code is compiled using Objective-C garbage collection (i.e.,
+code is compiled with the flag -fobjc-gc or -fobjc-gc-only),
+scan-build 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 only when using garbage
+collection:
+
+
Custom Assertion Handlers
diff --git a/www/analyzer/images/example_cf_returns_retained.png b/www/analyzer/images/example_cf_returns_retained.png
new file mode 100644
index 0000000000..3a3cb973a9
Binary files /dev/null and b/www/analyzer/images/example_cf_returns_retained.png differ
diff --git a/www/analyzer/images/example_cf_returns_retained_gc.png b/www/analyzer/images/example_cf_returns_retained_gc.png
new file mode 100644
index 0000000000..023f1a2f20
Binary files /dev/null and b/www/analyzer/images/example_cf_returns_retained_gc.png differ