From c77a55126fcad66fb086f8e100a494caa2496a2d Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Thu, 1 Jul 2010 07:10:59 +0000 Subject: [PATCH] ExplodedGraph never uses ASTContext, remove it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107388 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Checker/PathSensitive/ExplodedGraph.h | 10 ++-------- include/clang/Checker/PathSensitive/GRCoreEngine.h | 8 ++++---- include/clang/Checker/PathSensitive/GRExprEngine.h | 3 ++- lib/Checker/BugReporter.cpp | 2 +- lib/Checker/GRExprEngine.cpp | 6 +++--- 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/clang/Checker/PathSensitive/ExplodedGraph.h b/include/clang/Checker/PathSensitive/ExplodedGraph.h index c09c89312e..c875a2308b 100644 --- a/include/clang/Checker/PathSensitive/ExplodedGraph.h +++ b/include/clang/Checker/PathSensitive/ExplodedGraph.h @@ -36,7 +36,6 @@ namespace clang { class GRState; class CFG; -class ASTContext; class ExplodedGraph; //===----------------------------------------------------------------------===// @@ -240,9 +239,6 @@ protected: /// and successor groups. BumpVectorContext BVC; - /// Ctx - The ASTContext used to "interpret" CodeDecl. - ASTContext& Ctx; - /// NumNodes - The number of nodes in the graph. unsigned NumNodes; @@ -256,7 +252,7 @@ public: bool* IsNew = 0); ExplodedGraph* MakeEmptyGraph() const { - return new ExplodedGraph(Ctx); + return new ExplodedGraph(); } /// addRoot - Add an untyped node to the set of roots. @@ -271,7 +267,7 @@ public: return V; } - ExplodedGraph(ASTContext& ctx) : Ctx(ctx), NumNodes(0) {} + ExplodedGraph() : NumNodes(0) {} ~ExplodedGraph() {} @@ -318,8 +314,6 @@ public: llvm::BumpPtrAllocator & getAllocator() { return BVC.getAllocator(); } BumpVectorContext &getNodeAllocator() { return BVC; } - ASTContext& getContext() { return Ctx; } - typedef llvm::DenseMap NodeMap; std::pair diff --git a/include/clang/Checker/PathSensitive/GRCoreEngine.h b/include/clang/Checker/PathSensitive/GRCoreEngine.h index 936f18b97b..7f101dca97 100644 --- a/include/clang/Checker/PathSensitive/GRCoreEngine.h +++ b/include/clang/Checker/PathSensitive/GRCoreEngine.h @@ -109,8 +109,8 @@ private: public: /// Construct a GRCoreEngine object to analyze the provided CFG using /// a DFS exploration of the exploded graph. - GRCoreEngine(ASTContext& ctx, GRSubEngine& subengine) - : SubEngine(subengine), G(new ExplodedGraph(ctx)), + GRCoreEngine(GRSubEngine& subengine) + : SubEngine(subengine), G(new ExplodedGraph()), WList(GRWorkList::MakeBFS()), BCounterFactory(G->getAllocator()), BlockAborted(false) {} @@ -118,8 +118,8 @@ public: /// Construct a GRCoreEngine object to analyze the provided CFG and to /// use the provided worklist object to execute the worklist algorithm. /// The GRCoreEngine object assumes ownership of 'wlist'. - GRCoreEngine(ASTContext& ctx, GRWorkList* wlist, GRSubEngine& subengine) - : SubEngine(subengine), G(new ExplodedGraph(ctx)), WList(wlist), + GRCoreEngine(GRWorkList* wlist, GRSubEngine& subengine) + : SubEngine(subengine), G(new ExplodedGraph()), WList(wlist), BCounterFactory(G->getAllocator()), BlockAborted(false) {} diff --git a/include/clang/Checker/PathSensitive/GRExprEngine.h b/include/clang/Checker/PathSensitive/GRExprEngine.h index a302ea4eb0..8eaf3f4a97 100644 --- a/include/clang/Checker/PathSensitive/GRExprEngine.h +++ b/include/clang/Checker/PathSensitive/GRExprEngine.h @@ -16,6 +16,7 @@ #ifndef LLVM_CLANG_ANALYSIS_GREXPRENGINE #define LLVM_CLANG_ANALYSIS_GREXPRENGINE +#include "clang/Checker/PathSensitive/AnalysisManager.h" #include "clang/Checker/PathSensitive/GRSubEngine.h" #include "clang/Checker/PathSensitive/GRCoreEngine.h" #include "clang/Checker/PathSensitive/GRState.h" @@ -117,7 +118,7 @@ public: } /// getContext - Return the ASTContext associated with this analysis. - ASTContext& getContext() const { return G.getContext(); } + ASTContext& getContext() const { return AMgr.getASTContext(); } AnalysisManager &getAnalysisManager() const { return AMgr; } diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp index 3bcc03f4f2..560953f358 100644 --- a/lib/Checker/BugReporter.cpp +++ b/lib/Checker/BugReporter.cpp @@ -1403,7 +1403,7 @@ MakeReportGraph(const ExplodedGraph* G, // Create a new (third!) graph with a single path. This is the graph // that will be returned to the caller. - ExplodedGraph *GNew = new ExplodedGraph(GTrim->getContext()); + ExplodedGraph *GNew = new ExplodedGraph(); // Sometimes the trimmed graph can contain a cycle. Perform a reverse BFS // to the root node, and then construct a new graph that contains only diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index 7b4bfb9b02..723106e1df 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -379,10 +379,10 @@ static void RegisterInternalChecks(GRExprEngine &Eng) { GRExprEngine::GRExprEngine(AnalysisManager &mgr, GRTransferFuncs *tf) : AMgr(mgr), - CoreEngine(mgr.getASTContext(), *this), + CoreEngine(*this), G(CoreEngine.getGraph()), Builder(NULL), - StateMgr(G.getContext(), mgr.getStoreManagerCreator(), + StateMgr(getContext(), mgr.getStoreManagerCreator(), mgr.getConstraintManagerCreator(), G.getAllocator(), *this), SymMgr(StateMgr.getSymbolManager()), @@ -390,7 +390,7 @@ GRExprEngine::GRExprEngine(AnalysisManager &mgr, GRTransferFuncs *tf) SVator(ValMgr.getSValuator()), CurrentStmt(NULL), NSExceptionII(NULL), NSExceptionInstanceRaiseSelectors(NULL), - RaiseSel(GetNullarySelector("raise", G.getContext())), + RaiseSel(GetNullarySelector("raise", getContext())), BR(mgr, *this), TF(tf) { // Register internal checks. RegisterInternalChecks(*this); -- 2.40.0