summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-10-11 22:59:16 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-10-11 22:59:16 +0000
commit41dc8de6ae9f5ac1d39e5b8a86c2990a5c1feb9c (patch)
tree37676dece6954d1a545c2f1f2ac6b66f76407caf /clang/lib
parent4733be6e7bbde89e4c10bfdaeeb542fe297e0150 (diff)
downloadbcm5719-llvm-41dc8de6ae9f5ac1d39e5b8a86c2990a5c1feb9c.tar.gz
bcm5719-llvm-41dc8de6ae9f5ac1d39e5b8a86c2990a5c1feb9c.zip
[analyzer] Retain count checker for OSObject: recognize OSDynamicCast
For now, tresting the cast as a no-op, and disregarding the case where the output becomes null due to the type mismatch. rdar://45174557 Differential Revision: https://reviews.llvm.org/D53156 llvm-svn: 344311
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
index e5d27f577d1..ca58f14985c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
@@ -774,12 +774,23 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
// annotate attribute. If it does, we will not inline it.
bool hasTrustedImplementationAnnotation = false;
+ const LocationContext *LCtx = C.getLocationContext();
+
+ // Process OSDynamicCast: should just return the first argument.
+ // For now, tresting the cast as a no-op, and disregarding the case where
+ // the output becomes null due to the type mismatch.
+ if (FD->getNameAsString() == "safeMetaCast") {
+ state = state->BindExpr(CE, LCtx,
+ state->getSVal(CE->getArg(0), LCtx));
+ C.addTransition(state);
+ return true;
+ }
+
// See if it's one of the specific functions we know how to eval.
if (!SmrMgr.canEval(CE, FD, hasTrustedImplementationAnnotation))
return false;
// Bind the return value.
- const LocationContext *LCtx = C.getLocationContext();
SVal RetVal = state->getSVal(CE->getArg(0), LCtx);
if (RetVal.isUnknown() ||
(hasTrustedImplementationAnnotation && !ResultTy.isNull())) {
OpenPOWER on IntegriCloud