diff options
Diffstat (limited to 'include')
5 files changed, 32 insertions, 69 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 <typename T> const T* getLocationAs() const { return llvm::dyn_cast<T>(&Location); } |