diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-08-17 21:43:27 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-08-17 21:43:27 +0000 |
commit | 9af34252a329a83d09a7219439559e8f60bed53c (patch) | |
tree | 3f50b58da5b0a2df62d332ec335b891e2a0bef30 | |
parent | d360121f4ed75a7eb5995312ba1f3b53206c372a (diff) |
[analyzer] [NFC] Minor refactoring of ISL-specific code in RetainCountChecker
Differential Revision: https://reviews.llvm.org/D50879
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340098 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp | 15 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp | 8 |
2 files changed, 9 insertions, 14 deletions
diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp index 89b487aa01..a8957e1704 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -765,9 +765,7 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const { bool hasTrustedImplementationAnnotation = false; // See if it's one of the specific functions we know how to eval. - bool canEval = SmrMgr.canEval(CE, FD, hasTrustedImplementationAnnotation); - - if (!canEval) + if (!SmrMgr.canEval(CE, FD, hasTrustedImplementationAnnotation)) return false; // Bind the return value. @@ -1235,11 +1233,8 @@ RetainCountChecker::processLeaks(ProgramStateRef state, return N; } -static bool isGeneralizedObjectRef(QualType Ty) { - if (Ty.getAsString().substr(0, 4) == "isl_") - return true; - else - return false; +static bool isISLObjectRef(QualType Ty) { + return StringRef(Ty.getAsString()).startswith("isl_"); } void RetainCountChecker::checkBeginFunction(CheckerContext &Ctx) const { @@ -1263,9 +1258,9 @@ void RetainCountChecker::checkBeginFunction(CheckerContext &Ctx) const { QualType Ty = Param->getType(); const ArgEffect *AE = CalleeSideArgEffects.lookup(idx); - if (AE && *AE == DecRef && isGeneralizedObjectRef(Ty)) { + if (AE && *AE == DecRef && isISLObjectRef(Ty)) { state = setRefBinding(state, Sym, RefVal::makeOwned(RetEffect::ObjKind::Generalized, Ty)); - } else if (isGeneralizedObjectRef(Ty)) { + } else if (isISLObjectRef(Ty)) { state = setRefBinding( state, Sym, RefVal::makeNotOwned(RetEffect::ObjKind::Generalized, Ty)); diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp index 77699cc2c7..18813741f2 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountSummaries.cpp @@ -482,10 +482,10 @@ bool RetainSummaryManager::canEval(const CallExpr *CE, return isRetain(FD, FName) || isAutorelease(FD, FName) || isMakeCollectable(FName); - if (FD->getDefinition()) { - bool out = isTrustedReferenceCountImplementation(FD->getDefinition()); - hasTrustedImplementationAnnotation = out; - return out; + const FunctionDecl* FDD = FD->getDefinition(); + if (FDD && isTrustedReferenceCountImplementation(FDD)) { + hasTrustedImplementationAnnotation = true; + return true; } } |