diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-10-31 17:38:29 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-10-31 17:38:29 +0000 |
commit | 6fd5c86d9805bfbe1301cf255a0ce45565c5e28e (patch) | |
tree | 35eeab027d0e7620bd1edf4b9a918d358672609e /clang/lib | |
parent | 57ef3a02e21a8f94d7a9c6d2fa8ea4996d52ea03 (diff) | |
download | bcm5719-llvm-6fd5c86d9805bfbe1301cf255a0ce45565c5e28e.tar.gz bcm5719-llvm-6fd5c86d9805bfbe1301cf255a0ce45565c5e28e.zip |
[analyzer] RetainCountChecker: for now, do not trust the summaries of inlined code
Trusting summaries of inlined code would require a more thorough work,
as the current approach was causing too many false positives, as the new
example in test. The culprit lies in the fact that we currently escape
all variables written into a field (but not passed off to unknown
functions!), which can result in inconsistent behavior.
rdar://45655344
Differential Revision: https://reviews.llvm.org/D53902
llvm-svn: 345746
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp | 12 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp | 9 |
2 files changed, 7 insertions, 14 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp index 7db1465fa1b..3431b1554a1 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -420,13 +420,6 @@ void RetainCountChecker::processSummaryOfInlined(const RetainSummary &Summ, RetEffect RE = Summ.getRetEffect(); if (SymbolRef Sym = CallOrMsg.getReturnValue().getAsSymbol()) { - if (const auto *MCall = dyn_cast<CXXMemberCall>(&CallOrMsg)) { - if (Optional<RefVal> updatedRefVal = - refValFromRetEffect(RE, MCall->getResultType())) { - state = setRefBinding(state, Sym, *updatedRefVal); - } - } - if (RE.getKind() == RetEffect::NoRetHard) state = removeRefBinding(state, Sym); } @@ -1103,9 +1096,8 @@ RetainCountChecker::checkRegionChanges(ProgramStateRef state, WhitelistedSymbols.insert(SR->getSymbol()); } - for (InvalidatedSymbols::const_iterator I=invalidated->begin(), - E = invalidated->end(); I!=E; ++I) { - SymbolRef sym = *I; + for (SymbolRef sym : + llvm::make_range(invalidated->begin(), invalidated->end())) { if (WhitelistedSymbols.count(sym)) continue; // Remove any existing reference-count binding. diff --git a/clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp b/clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp index efaab64c770..b0e26bae961 100644 --- a/clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp @@ -101,10 +101,11 @@ static bool isOSObjectRelated(const CXXMethodDecl *MD) { return true; for (ParmVarDecl *Param : MD->parameters()) { - QualType PT = Param->getType(); - if (CXXRecordDecl *RD = PT->getPointeeType()->getAsCXXRecordDecl()) - if (isOSObjectSubclass(RD)) - return true; + QualType PT = Param->getType()->getPointeeType(); + if (!PT.isNull()) + if (CXXRecordDecl *RD = PT->getAsCXXRecordDecl()) + if (isOSObjectSubclass(RD)) + return true; } return false; |