diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp index 8585a02aab0..578f282a190 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -776,31 +776,27 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const { 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. - SVal RetVal = state->getSVal(CE->getArg(0), LCtx); - if (RetVal.isUnknown() || - (hasTrustedImplementationAnnotation && !ResultTy.isNull())) { + // For now, all the functions which we can evaluate and which take + // at least one argument are identities. + if (CE->getNumArgs() >= 1) { + SVal RetVal = state->getSVal(CE->getArg(0), LCtx); + // If the receiver is unknown or the function has // 'rc_ownership_trusted_implementation' annotate attribute, conjure a // return value. - SValBuilder &SVB = C.getSValBuilder(); - RetVal = SVB.conjureSymbolVal(nullptr, CE, LCtx, ResultTy, C.blockCount()); + if (RetVal.isUnknown() || + (hasTrustedImplementationAnnotation && !ResultTy.isNull())) { + SValBuilder &SVB = C.getSValBuilder(); + RetVal = + SVB.conjureSymbolVal(nullptr, CE, LCtx, ResultTy, C.blockCount()); + } + state = state->BindExpr(CE, LCtx, RetVal, false); } - state = state->BindExpr(CE, LCtx, RetVal, false); C.addTransition(state); return true; |