r174104 - [analyzer]RetainCount: Fix an autorelease related false positive.
Anna Zaks
ganna at apple.com
Thu Jan 31 14:36:17 PST 2013
Author: zaks
Date: Thu Jan 31 16:36:17 2013
New Revision: 174104
URL: http://llvm.org/viewvc/llvm-project?rev=174104&view=rev
Log:
[analyzer]RetainCount: Fix an autorelease related false positive.
The Cnt variable is adjusted (incremented) for simplification of
checking logic. The increment should not be stored in the state.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=174104&r1=174103&r2=174104&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Thu Jan 31 16:36:17 2013
@@ -3487,7 +3487,7 @@ RetainCountChecker::handleAutoreleaseCou
else
V = V ^ RefVal::NotOwned;
} else {
- V.setCount(Cnt - ACnt);
+ V.setCount(V.getCount() - ACnt);
V.setAutoreleaseCount(0);
}
return setRefBinding(state, Sym, V);
Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=174104&r1=174103&r2=174104&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Thu Jan 31 16:36:17 2013
@@ -1784,6 +1784,13 @@ extern id NSApp;
id contextObject = (id)contextInfo;
[contextObject release];
}
+
+- (id)copyAutoreleaseRadar13081402 {
+ id x = [[[NSString alloc] initWithUTF8String:"foo"] autorelease];
+ [x retain];
+ return x; // no warning
+}
+
@end
//===----------------------------------------------------------------------===//
// Test returning allocated memory in a struct.
@@ -1961,6 +1968,7 @@ void test_drain() {
}
+
// CHECK: <key>diagnostics</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
More information about the cfe-commits
mailing list