From b317f8f5ca8737a5bbad97a3f7566a2dbd2ed61b Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Thu, 10 Sep 2009 05:44:00 +0000 Subject: [PATCH] Make AnalysisManager stateless. Now other analyzer components only depends on local node information. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81433 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Analysis/LocalCheckers.h | 3 +- .../Analysis/PathSensitive/AnalysisContext.h | 4 + .../Analysis/PathSensitive/AnalysisManager.h | 75 ++++--------- .../Analysis/PathSensitive/BugReporter.h | 11 -- .../Analysis/PathSensitive/ExplodedGraph.h | 8 +- lib/Analysis/AnalysisManager.cpp | 8 +- lib/Analysis/BugReporter.cpp | 16 +-- lib/Analysis/CFRefCount.cpp | 10 +- lib/Analysis/CheckDeadStores.cpp | 9 +- lib/Analysis/GRExprEngine.cpp | 26 ++--- lib/Frontend/AnalysisConsumer.cpp | 101 ++++++++++-------- 11 files changed, 118 insertions(+), 153 deletions(-) diff --git a/include/clang/Analysis/LocalCheckers.h b/include/clang/Analysis/LocalCheckers.h index ffcffe3305..1da15fbae6 100644 --- a/include/clang/Analysis/LocalCheckers.h +++ b/include/clang/Analysis/LocalCheckers.h @@ -32,7 +32,8 @@ class ObjCImplementationDecl; class LangOptions; class GRExprEngine; -void CheckDeadStores(LiveVariables& L, BugReporter& BR); +void CheckDeadStores(CFG &cfg, LiveVariables &L, ParentMap &map, + BugReporter& BR); void CheckUninitializedValues(CFG& cfg, ASTContext& Ctx, Diagnostic& Diags, bool FullUninitTaint=false); diff --git a/include/clang/Analysis/PathSensitive/AnalysisContext.h b/include/clang/Analysis/PathSensitive/AnalysisContext.h index 22f9902975..ab035386c5 100644 --- a/include/clang/Analysis/PathSensitive/AnalysisContext.h +++ b/include/clang/Analysis/PathSensitive/AnalysisContext.h @@ -91,6 +91,10 @@ public: return getAnalysisContext()->getLiveVariables(); } + ParentMap &getParentMap() const { + return getAnalysisContext()->getParentMap(); + } + const ImplicitParamDecl *getSelfDecl() const { return Ctx->getSelfDecl(); } diff --git a/include/clang/Analysis/PathSensitive/AnalysisManager.h b/include/clang/Analysis/PathSensitive/AnalysisManager.h index 948bb1fe8a..868e3c06e4 100644 --- a/include/clang/Analysis/PathSensitive/AnalysisManager.h +++ b/include/clang/Analysis/PathSensitive/AnalysisManager.h @@ -22,9 +22,7 @@ namespace clang { class AnalysisManager : public BugReporterData { - AnalysisContextManager ContextMgr; - AnalysisContext *EntryContext; - + AnalysisContextManager AnaCtxMgr; LocationContextManager LocCtxMgr; ASTContext &Ctx; @@ -55,22 +53,7 @@ class AnalysisManager : public BugReporterData { bool TrimGraph; public: - AnalysisManager(Decl *d, ASTContext &ctx, Diagnostic &diags, - const LangOptions &lang, PathDiagnosticClient *pd, - StoreManagerCreator storemgr, - ConstraintManagerCreator constraintmgr, - bool displayProgress, bool vizdot, bool vizubi, - bool purge, bool eager, bool trim) - : Ctx(ctx), Diags(diags), LangInfo(lang), PD(pd), - CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), - AScope(ScopeDecl), DisplayedFunction(!displayProgress), - VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge), - EagerlyAssume(eager), TrimGraph(trim) { - - EntryContext = ContextMgr.getContext(d); - } - - AnalysisManager(ASTContext &ctx, Diagnostic &diags, + AnalysisManager(ASTContext &ctx, Diagnostic &diags, const LangOptions &lang, PathDiagnosticClient *pd, StoreManagerCreator storemgr, ConstraintManagerCreator constraintmgr, @@ -81,25 +64,7 @@ public: CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr), AScope(ScopeDecl), DisplayedFunction(!displayProgress), VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge), - EagerlyAssume(eager), TrimGraph(trim) { - - EntryContext = 0; - } - - void setEntryContext(Decl *D) { - EntryContext = ContextMgr.getContext(D); - DisplayedFunction = false; - } - - const Decl *getCodeDecl() const { - assert (AScope == ScopeDecl); - return EntryContext->getDecl(); - } - - Stmt *getBody() const { - assert (AScope == ScopeDecl); - return EntryContext->getBody(); - } + EagerlyAssume(eager), TrimGraph(trim) {} StoreManagerCreator getStoreManagerCreator() { return CreateStoreMgr; @@ -109,18 +74,6 @@ public: return CreateConstraintMgr; } - virtual CFG *getCFG() { - return EntryContext->getCFG(); - } - - virtual ParentMap &getParentMap() { - return EntryContext->getParentMap(); - } - - virtual LiveVariables *getLiveVariables() { - return EntryContext->getLiveVariables(); - } - virtual ASTContext &getASTContext() { return Ctx; } @@ -141,10 +94,6 @@ public: return PD.get(); } - StackFrameContext *getEntryStackFrame() { - return LocCtxMgr.getStackFrame(EntryContext, 0, 0); - } - bool shouldVisualizeGraphviz() const { return VisualizeEGDot; } bool shouldVisualizeUbigraph() const { return VisualizeEGUbi; } @@ -159,7 +108,23 @@ public: bool shouldEagerlyAssume() const { return EagerlyAssume; } - void DisplayFunction(); + void DisplayFunction(Decl *D); + + CFG *getCFG(Decl const *D) { + return AnaCtxMgr.getContext(D)->getCFG(); + } + + LiveVariables *getLiveVariables(Decl const *D) { + return AnaCtxMgr.getContext(D)->getLiveVariables(); + } + + ParentMap &getParentMap(Decl const *D) { + return AnaCtxMgr.getContext(D)->getParentMap(); + } + + StackFrameContext *getStackFrame(Decl const *D) { + return LocCtxMgr.getStackFrame(AnaCtxMgr.getContext(D), 0, 0); + } }; } diff --git a/include/clang/Analysis/PathSensitive/BugReporter.h b/include/clang/Analysis/PathSensitive/BugReporter.h index 55555c6df0..97d7c3d444 100644 --- a/include/clang/Analysis/PathSensitive/BugReporter.h +++ b/include/clang/Analysis/PathSensitive/BugReporter.h @@ -282,9 +282,6 @@ public: virtual PathDiagnosticClient* getPathDiagnosticClient() = 0; virtual ASTContext& getASTContext() = 0; virtual SourceManager& getSourceManager() = 0; - virtual CFG* getCFG() = 0; - virtual ParentMap& getParentMap() = 0; - virtual LiveVariables* getLiveVariables() = 0; }; class BugReporter { @@ -328,12 +325,6 @@ public: SourceManager& getSourceManager() { return D.getSourceManager(); } - CFG* getCFG() { return D.getCFG(); } - - ParentMap& getParentMap() { return D.getParentMap(); } - - LiveVariables* getLiveVariables() { return D.getLiveVariables(); } - virtual void GeneratePathDiagnostic(PathDiagnostic& PD, BugReportEquivClass& EQ) {} @@ -457,8 +448,6 @@ public: return BR.getSourceManager(); } - const Decl &getCodeDecl(); - const CFG &getCFG(); virtual BugReport::NodeResolver& getNodeResolver() = 0; }; diff --git a/include/clang/Analysis/PathSensitive/ExplodedGraph.h b/include/clang/Analysis/PathSensitive/ExplodedGraph.h index fc41333f27..d8659c2302 100644 --- a/include/clang/Analysis/PathSensitive/ExplodedGraph.h +++ b/include/clang/Analysis/PathSensitive/ExplodedGraph.h @@ -119,10 +119,14 @@ public: CFG &getCFG() const { return *getLocationContext()->getCFG(); } - const GRState* getState() const { - return State; + ParentMap &getParentMap() const {return getLocationContext()->getParentMap();} + + LiveVariables &getLiveVariables() const { + return *getLocationContext()->getLiveVariables(); } + const GRState* getState() const { return State; } + template const T* getLocationAs() const { return llvm::dyn_cast(&Location); } diff --git a/lib/Analysis/AnalysisManager.cpp b/lib/Analysis/AnalysisManager.cpp index 623db17b92..1aa459a28d 100644 --- a/lib/Analysis/AnalysisManager.cpp +++ b/lib/Analysis/AnalysisManager.cpp @@ -16,7 +16,7 @@ using namespace clang; -void AnalysisManager::DisplayFunction() { +void AnalysisManager::DisplayFunction(Decl *D) { if (DisplayedFunction) return; @@ -24,12 +24,12 @@ void AnalysisManager::DisplayFunction() { DisplayedFunction = true; // FIXME: Is getCodeDecl() always a named decl? - if (isa(getCodeDecl()) || - isa(getCodeDecl())) { - const NamedDecl *ND = cast(getCodeDecl()); + if (isa(D) || isa(D)) { + const NamedDecl *ND = cast(D); SourceManager &SM = getASTContext().getSourceManager(); llvm::errs() << "ANALYZE: " << SM.getPresumedLoc(ND->getLocation()).getFilename() << ' ' << ND->getNameAsString() << '\n'; } } + diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 23ca53d6e9..c15161c708 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -36,14 +36,6 @@ BugReporterContext::~BugReporterContext() { if ((*I)->isOwnedByReporterContext()) delete *I; } -const Decl& BugReporterContext::getCodeDecl() { - return *BR.getEngine().getAnalysisManager().getCodeDecl(); -} - -const CFG& BugReporterContext::getCFG() { - return *BR.getEngine().getAnalysisManager().getCFG(); -} - //===----------------------------------------------------------------------===// // Helper routines for walking the ExplodedGraph and fetching statements. //===----------------------------------------------------------------------===// @@ -158,11 +150,9 @@ public: PathDiagnosticLocation ExecutionContinues(llvm::raw_string_ostream& os, const ExplodedNode* N); - ParentMap& getParentMap() { - if (PM.get() == 0) - PM.reset(new ParentMap(getCodeDecl().getBody())); - return *PM.get(); - } + Decl const &getCodeDecl() { return R->getEndNode()->getCodeDecl(); } + + ParentMap& getParentMap() { return R->getEndNode()->getParentMap(); } const Stmt *getParent(const Stmt *S) { return getParentMap().getParent(S); diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index e511f76195..8427679316 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -2641,7 +2641,7 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC, } if (!L.isValid()) { - const Decl &D = BRC.getCodeDecl(); + const Decl &D = EndN->getCodeDecl(); L = PathDiagnosticLocation(D.getBodyRBrace(), SMgr); } @@ -2660,7 +2660,7 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC, // FIXME: Per comments in rdar://6320065, "create" only applies to CF // ojbects. Only "copy", "alloc", "retain" and "new" transfer ownership // to the caller for NS objects. - ObjCMethodDecl& MD = cast(BRC.getCodeDecl()); + ObjCMethodDecl& MD = cast(EndN->getCodeDecl()); os << " is returned from a method whose name ('" << MD.getSelector().getAsString() << "') does not contain 'copy' or otherwise starts with" @@ -2668,7 +2668,7 @@ CFRefLeakReport::getEndPath(BugReporterContext& BRC, " in the Memory Management Guide for Cocoa (object leaked)"; } else if (RV->getKind() == RefVal::ErrorGCLeakReturned) { - ObjCMethodDecl& MD = cast(BRC.getCodeDecl()); + ObjCMethodDecl& MD = cast(EndN->getCodeDecl()); os << " and returned from method '" << MD.getSelector().getAsString() << "' is potentially leaked when using garbage collection. Callers " "of this method do not expect a returned object with a +1 retain " @@ -3186,7 +3186,7 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, // Any leaks or other errors? if (X.isReturnedOwned() && X.getCount() == 0) { - const Decl *CD = Eng.getAnalysisManager().getCodeDecl(); + Decl const *CD = &Pred->getCodeDecl(); if (const ObjCMethodDecl* MD = dyn_cast(CD)) { const RetainSummary &Summ = *Summaries.getMethodSummary(MD); RetEffect RE = Summ.getRetEffect(); @@ -3229,7 +3229,7 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, } } else if (X.isReturnedNotOwned()) { - const Decl *CD = Eng.getAnalysisManager().getCodeDecl(); + Decl const *CD = &Pred->getCodeDecl(); if (const ObjCMethodDecl* MD = dyn_cast(CD)) { const RetainSummary &Summ = *Summaries.getMethodSummary(MD); if (Summ.getRetEffect().isOwned()) { diff --git a/lib/Analysis/CheckDeadStores.cpp b/lib/Analysis/CheckDeadStores.cpp index 716affb846..d5cb7ca7fd 100644 --- a/lib/Analysis/CheckDeadStores.cpp +++ b/lib/Analysis/CheckDeadStores.cpp @@ -251,9 +251,10 @@ public: } // end anonymous namespace -void clang::CheckDeadStores(LiveVariables& L, BugReporter& BR) { - FindEscaped FS(BR.getCFG()); +void clang::CheckDeadStores(CFG &cfg, LiveVariables &L, ParentMap &pmap, + BugReporter& BR) { + FindEscaped FS(&cfg); FS.getCFG().VisitBlockStmts(FS); - DeadStoreObs A(BR.getContext(), BR, BR.getParentMap(), FS.Escaped); - L.runOnAllBlocks(*BR.getCFG(), &A); + DeadStoreObs A(BR.getContext(), BR, pmap, FS.Escaped); + L.runOnAllBlocks(cfg, &A); } diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index ff9554c836..986af1023b 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -262,7 +262,8 @@ void GRExprEngine::ProcessStmt(Stmt* S, GRStmtNodeBuilder& builder) { Builder->setAuditor(BatchAuditor.get()); // Create the cleaned state. - SymbolReaper SymReaper(*AMgr.getLiveVariables(), SymMgr); + SymbolReaper SymReaper(Builder->getBasePredecessor()->getLiveVariables(), + SymMgr); CleanedState = AMgr.shouldPurgeDead() ? StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt, SymReaper) : EntryNode->getState(); @@ -1670,7 +1671,8 @@ void GRExprEngine::VisitCallRec(CallExpr* CE, ExplodedNode* Pred, static std::pair EagerlyAssumeTag = std::pair(&EagerlyAssumeTag,0); -void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, Expr *Ex) { +void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, + Expr *Ex) { for (ExplodedNodeSet::iterator I=Src.begin(), E=Src.end(); I!=E; ++I) { ExplodedNode *Pred = *I; @@ -1713,9 +1715,8 @@ void GRExprEngine::EvalEagerlyAssume(ExplodedNodeSet &Dst, ExplodedNodeSet &Src, // Transfer function: Objective-C ivar references. //===----------------------------------------------------------------------===// -void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex, - ExplodedNode* Pred, ExplodedNodeSet& Dst, - bool asLValue) { +void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex, ExplodedNode* Pred, + ExplodedNodeSet& Dst, bool asLValue) { Expr* Base = cast(Ex->getBase()); ExplodedNodeSet Tmp; @@ -1738,7 +1739,7 @@ void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex, //===----------------------------------------------------------------------===// void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, - ExplodedNode* Pred, ExplodedNodeSet& Dst) { + ExplodedNode* Pred, ExplodedNodeSet& Dst) { // ObjCForCollectionStmts are processed in two places. This method // handles the case where an ObjCForCollectionStmt* occurs as one of the @@ -1786,7 +1787,7 @@ void GRExprEngine::VisitObjCForCollectionStmt(ObjCForCollectionStmt* S, } void GRExprEngine::VisitObjCForCollectionStmtAux(ObjCForCollectionStmt* S, - ExplodedNode* Pred, ExplodedNodeSet& Dst, + ExplodedNode* Pred, ExplodedNodeSet& Dst, SVal ElementV) { @@ -1845,7 +1846,7 @@ void GRExprEngine::VisitObjCMessageExpr(ObjCMessageExpr* ME, ExplodedNode* Pred, void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME, ObjCMessageExpr::arg_iterator AI, ObjCMessageExpr::arg_iterator AE, - ExplodedNode* Pred, ExplodedNodeSet& Dst) { + ExplodedNode* Pred, ExplodedNodeSet& Dst) { if (AI == AE) { // Process the receiver. @@ -1854,7 +1855,8 @@ void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME, ExplodedNodeSet Tmp; Visit(Receiver, Pred, Tmp); - for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI) + for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; + ++NI) VisitObjCMessageExprDispatchHelper(ME, *NI, Dst); return; @@ -1869,7 +1871,7 @@ void GRExprEngine::VisitObjCMessageExprArgHelper(ObjCMessageExpr* ME, ++AI; - for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end(); NI != NE; ++NI) + for (ExplodedNodeSet::iterator NI = Tmp.begin(), NE = Tmp.end();NI != NE;++NI) VisitObjCMessageExprArgHelper(ME, AI, AE, *NI, Dst); } @@ -1910,7 +1912,7 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, // Check if the receiver was nil and the return value a struct. if (RetTy->isRecordType()) { - if (BR.getParentMap().isConsumedExpr(ME)) { + if (Pred->getParentMap().isConsumedExpr(ME)) { // The [0 ...] expressions will return garbage. Flag either an // explicit or implicit error. Because of the structure of this // function we currently do not bifurfacte the state graph at @@ -1929,7 +1931,7 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME, else { ASTContext& Ctx = getContext(); if (RetTy != Ctx.VoidTy) { - if (BR.getParentMap().isConsumedExpr(ME)) { + if (Pred->getParentMap().isConsumedExpr(ME)) { // sizeof(void *) const uint64_t voidPtrSize = Ctx.getTypeSize(Ctx.VoidPtrTy); // sizeof(return type) diff --git a/lib/Frontend/AnalysisConsumer.cpp b/lib/Frontend/AnalysisConsumer.cpp index 2d07d89e04..67328da661 100644 --- a/lib/Frontend/AnalysisConsumer.cpp +++ b/lib/Frontend/AnalysisConsumer.cpp @@ -45,7 +45,7 @@ static ExplodedNode::Auditor* CreateUbiViz(); //===----------------------------------------------------------------------===// namespace { - typedef void (*CodeAction)(AnalysisManager& Mgr); + typedef void (*CodeAction)(AnalysisManager& Mgr, Decl *D); } // end anonymous namespace //===----------------------------------------------------------------------===// @@ -223,10 +223,23 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) { } void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { - if (!TranslationUnitActions.empty()) { - for (Actions::iterator I = TranslationUnitActions.begin(), + // Find the entry function definition. + FunctionDecl *FD = 0; + TranslationUnitDecl *TU = Ctx->getTranslationUnitDecl(); + for (DeclContext::decl_iterator I = TU->decls_begin(), E = TU->decls_end(); + I != E; ++I) { + if (FunctionDecl *fd = dyn_cast(*I)) + if (fd->isThisDeclarationADefinition() && + fd->getNameAsString() == Opts.AnalyzeSpecificFunction) { + FD = fd; + break; + } + } + + if(!TranslationUnitActions.empty()) { + for (Actions::iterator I = TranslationUnitActions.begin(), E = TranslationUnitActions.end(); I != E; ++I) - (*I)(*Mgr); + (*I)(*Mgr, FD); } if (!ObjCImplementationActions.empty()) { @@ -245,7 +258,7 @@ void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) { Mgr.reset(NULL); } -void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) { +void AnalysisConsumer::HandleCode(Decl *D, Stmt* Body, Actions& actions) { // Don't run the actions if an error has occured with parsing the file. if (Diags.hasErrorOccurred()) @@ -257,41 +270,40 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) { !Ctx->getSourceManager().isFromMainFile(D->getLocation())) return; - Mgr->setEntryContext(D); - // Dispatch on the actions. for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I) - (*I)(*Mgr); + (*I)(*Mgr, D); } //===----------------------------------------------------------------------===// // Analyses //===----------------------------------------------------------------------===// -static void ActionWarnDeadStores(AnalysisManager& mgr) { - if (LiveVariables* L = mgr.getLiveVariables()) { +static void ActionWarnDeadStores(AnalysisManager& mgr, Decl *D) { + if (LiveVariables *L = mgr.getLiveVariables(D)) { BugReporter BR(mgr); - CheckDeadStores(*L, BR); + CheckDeadStores(*mgr.getCFG(D), *L, mgr.getParentMap(D), BR); } } -static void ActionWarnUninitVals(AnalysisManager& mgr) { - if (CFG* c = mgr.getCFG()) +static void ActionWarnUninitVals(AnalysisManager& mgr, Decl *D) { + if (CFG* c = mgr.getCFG(D)) CheckUninitializedValues(*c, mgr.getASTContext(), mgr.getDiagnostic()); } -static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, +static void ActionGRExprEngine(AnalysisManager& mgr, Decl *D, + GRTransferFuncs* tf, bool StandardWarnings = true) { llvm::OwningPtr TF(tf); // Display progress. - mgr.DisplayFunction(); + mgr.DisplayFunction(D); // Construct the analysis engine. - LiveVariables* L = mgr.getLiveVariables(); + LiveVariables* L = mgr.getLiveVariables(D); if (!L) return; GRExprEngine Eng(mgr); @@ -300,7 +312,7 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, if (StandardWarnings) { Eng.RegisterInternalChecks(); - RegisterAppleChecks(Eng, *mgr.getCodeDecl()); + RegisterAppleChecks(Eng, *D); } // Set the graph auditor. @@ -311,7 +323,7 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, } // Execute the worklist algorithm. - Eng.ExecuteWorkList(mgr.getEntryStackFrame()); + Eng.ExecuteWorkList(mgr.getStackFrame(D)); // Release the auditor (if any) so that it doesn't monitor the graph // created BugReporter. @@ -325,82 +337,79 @@ static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf, Eng.getBugReporter().FlushReports(); } -static void ActionCheckerCFRefAux(AnalysisManager& mgr, bool GCEnabled, - bool StandardWarnings) { +static void ActionCheckerCFRefAux(AnalysisManager& mgr, Decl *D, + bool GCEnabled, bool StandardWarnings) { GRTransferFuncs* TF = MakeCFRefCountTF(mgr.getASTContext(), GCEnabled, mgr.getLangOptions()); - ActionGRExprEngine(mgr, TF, StandardWarnings); + ActionGRExprEngine(mgr, D, TF, StandardWarnings); } -static void ActionCheckerCFRef(AnalysisManager& mgr) { +static void ActionCheckerCFRef(AnalysisManager& mgr, Decl *D) { switch (mgr.getLangOptions().getGCMode()) { default: assert (false && "Invalid GC mode."); case LangOptions::NonGC: - ActionCheckerCFRefAux(mgr, false, true); + ActionCheckerCFRefAux(mgr, D, false, true); break; case LangOptions::GCOnly: - ActionCheckerCFRefAux(mgr, true, true); + ActionCheckerCFRefAux(mgr, D, true, true); break; case LangOptions::HybridGC: - ActionCheckerCFRefAux(mgr, false, true); - ActionCheckerCFRefAux(mgr, true, false); + ActionCheckerCFRefAux(mgr, D, false, true); + ActionCheckerCFRefAux(mgr, D, true, false); break; } } -static void ActionDisplayLiveVariables(AnalysisManager& mgr) { - if (LiveVariables* L = mgr.getLiveVariables()) { - mgr.DisplayFunction(); +static void ActionDisplayLiveVariables(AnalysisManager& mgr, Decl *D) { + if (LiveVariables* L = mgr.getLiveVariables(D)) { + mgr.DisplayFunction(D); L->dumpBlockLiveness(mgr.getSourceManager()); } } -static void ActionCFGDump(AnalysisManager& mgr) { - if (CFG* c = mgr.getCFG()) { - mgr.DisplayFunction(); +static void ActionCFGDump(AnalysisManager& mgr, Decl *D) { + if (CFG* c = mgr.getCFG(D)) { + mgr.DisplayFunction(D); c->dump(mgr.getLangOptions()); } } -static void ActionCFGView(AnalysisManager& mgr) { - if (CFG* c = mgr.getCFG()) { - mgr.DisplayFunction(); +static void ActionCFGView(AnalysisManager& mgr, Decl *D) { + if (CFG* c = mgr.getCFG(D)) { + mgr.DisplayFunction(D); c->viewCFG(mgr.getLangOptions()); } } -static void ActionSecuritySyntacticChecks(AnalysisManager &mgr) { +static void ActionSecuritySyntacticChecks(AnalysisManager &mgr, Decl *D) { BugReporter BR(mgr); - CheckSecuritySyntaxOnly(mgr.getCodeDecl(), BR); + CheckSecuritySyntaxOnly(D, BR); } -static void ActionWarnObjCDealloc(AnalysisManager& mgr) { +static void ActionWarnObjCDealloc(AnalysisManager& mgr, Decl *D) { if (mgr.getLangOptions().getGCMode() == LangOptions::GCOnly) return; BugReporter BR(mgr); - - CheckObjCDealloc(cast(mgr.getCodeDecl()), - mgr.getLangOptions(), BR); + CheckObjCDealloc(cast(D), mgr.getLangOptions(), BR); } -static void ActionWarnObjCUnusedIvars(AnalysisManager& mgr) { +static void ActionWarnObjCUnusedIvars(AnalysisManager& mgr, Decl *D) { BugReporter BR(mgr); - CheckObjCUnusedIvar(cast(mgr.getCodeDecl()), BR); + CheckObjCUnusedIvar(cast(D), BR); } -static void ActionWarnObjCMethSigs(AnalysisManager& mgr) { +static void ActionWarnObjCMethSigs(AnalysisManager& mgr, Decl *D) { BugReporter BR(mgr); - CheckObjCInstMethSignature(cast(mgr.getCodeDecl()), - BR); + CheckObjCInstMethSignature(cast(D), BR); } //===----------------------------------------------------------------------===// -- 2.40.0