aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-11-12 22:06:24 +0000
committerAnna Zaks <ganna@apple.com>2012-11-12 22:06:24 +0000
commite7ad14e18247ec6fc3d46b208829e3dac6d85a1d (patch)
treee378b2bb2875b0aa0b3961dc42a699536c281bc8
parent5ece32e3359ca34fcdab07829f5e9fdbfd157f78 (diff)
[analyzer] Fix a regression (from r 165079): compare canonical types.
Suppresses a leak false positive (radar://12663777). In addition, we'll need to rewrite the adjustReturnValue() method not to return UnknownVal by default, but rather assert in cases we cannot handle. To make it possible, we need to correctly handle some of the edge cases we already know about. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167762 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp2
-rw-r--r--test/Analysis/retain-release-inline.m16
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
index 3c1c412af5..5b88a45495 100644
--- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -137,6 +137,8 @@ static SVal adjustReturnValue(SVal V, QualType ExpectedTy, QualType ActualTy,
return V;
// If the types already match, don't do any unnecessary work.
+ ExpectedTy = ExpectedTy.getCanonicalType();
+ ActualTy = ActualTy.getCanonicalType();
if (ExpectedTy == ActualTy)
return V;
diff --git a/test/Analysis/retain-release-inline.m b/test/Analysis/retain-release-inline.m
index a06b3531fe..6ff9e9a552 100644
--- a/test/Analysis/retain-release-inline.m
+++ b/test/Analysis/retain-release-inline.m
@@ -343,5 +343,21 @@ void test_test_return_inline_2(char *bytes) {
CFRelease(str);
}
+extern CFStringRef getString(void);
+CFStringRef testCovariantReturnType(void) __attribute__((cf_returns_retained));
+void usetestCovariantReturnType() {
+ CFStringRef S = ((void*)0);
+ S = testCovariantReturnType();
+ if (S)
+ CFRelease(S);
+}
+CFStringRef testCovariantReturnType() {
+ CFStringRef Str = ((void*)0);
+ Str = getString();
+ if (Str) {
+ CFRetain(Str);
+ }
+ return Str;
+}