diff options
| author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-08-18 03:22:11 +0000 |
|---|---|---|
| committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-08-18 03:22:11 +0000 |
| commit | bb3b7cff960298b2b838f3444356beba6d3a5b11 (patch) | |
| tree | 702db118aade98075be04764303214a126a1592b /clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp | |
| parent | 6ac2be0a987aed2d466716d0378d638d2866303f (diff) | |
| download | bcm5719-llvm-bb3b7cff960298b2b838f3444356beba6d3a5b11.tar.gz bcm5719-llvm-bb3b7cff960298b2b838f3444356beba6d3a5b11.zip | |
Revert "[analyzer] [NFC] Split up RetainSummaryManager from RetainCountChecker"
This reverts commit a786521fa66c72edd308baff0c08961b6d964fb1.
Bots haven't caught up yet, but broke modules build with:
../tools/clang/include/clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h:18:10:
fatal error: cyclic dependency in module 'Clang_StaticAnalyzer_Core':
Clang_StaticAnalyzer_Core -> Clang_Analysis ->
Clang_StaticAnalyzer_Checkers -> Clang_StaticAnalyzer_Core
^
llvm-svn: 340117
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp index 9d6c8314d82..a8957e1704e 100644 --- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp @@ -16,6 +16,7 @@ using namespace clang; using namespace ento; +using namespace objc_retain; using namespace retaincountchecker; using llvm::StrInStrNoCase; @@ -330,19 +331,7 @@ void RetainCountChecker::checkPostStmt(const ObjCIvarRefExpr *IRE, void RetainCountChecker::checkPostCall(const CallEvent &Call, CheckerContext &C) const { RetainSummaryManager &Summaries = getSummaryManager(C); - - // Leave null if no receiver. - QualType ReceiverType; - if (const auto *MC = dyn_cast<ObjCMethodCall>(&Call)) { - if (MC->isInstanceMessage()) { - SVal ReceiverV = MC->getReceiverSVal(); - if (SymbolRef Sym = ReceiverV.getAsLocSymbol()) - if (const RefVal *T = getRefBinding(C.getState(), Sym)) - ReceiverType = T->getType(); - } - } - - const RetainSummary *Summ = Summaries.getSummary(Call, ReceiverType); + const RetainSummary *Summ = Summaries.getSummary(Call, C.getState()); if (C.wasInlined) { processSummaryOfInlined(*Summ, Call, C); @@ -1399,6 +1388,45 @@ void RetainCountChecker::printState(raw_ostream &Out, ProgramStateRef State, } //===----------------------------------------------------------------------===// +// Implementation of the CallEffects API. +//===----------------------------------------------------------------------===// + +namespace clang { +namespace ento { +namespace objc_retain { + +// This is a bit gross, but it allows us to populate CallEffects without +// creating a bunch of accessors. This kind is very localized, so the +// damage of this macro is limited. +#define createCallEffect(D, KIND)\ + ASTContext &Ctx = D->getASTContext();\ + LangOptions L = Ctx.getLangOpts();\ + RetainSummaryManager M(Ctx, L.ObjCAutoRefCount);\ + const RetainSummary *S = M.get ## KIND ## Summary(D);\ + CallEffects CE(S->getRetEffect());\ + CE.Receiver = S->getReceiverEffect();\ + unsigned N = D->param_size();\ + for (unsigned i = 0; i < N; ++i) {\ + CE.Args.push_back(S->getArg(i));\ + } + +CallEffects CallEffects::getEffect(const ObjCMethodDecl *MD) { + createCallEffect(MD, Method); + return CE; +} + +CallEffects CallEffects::getEffect(const FunctionDecl *FD) { + createCallEffect(FD, Function); + return CE; +} + +#undef createCallEffect + +} // end namespace objc_retain +} // end namespace ento +} // end namespace clang + +//===----------------------------------------------------------------------===// // Checker registration. //===----------------------------------------------------------------------===// |

