diff options
-rw-r--r-- | include/clang/Analysis/PathSensitive/Environment.h | 11 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRState.h | 21 | ||||
-rw-r--r-- | lib/Analysis/Environment.cpp | 8 | ||||
-rw-r--r-- | lib/Analysis/GRState.cpp | 12 |
4 files changed, 22 insertions, 30 deletions
diff --git a/include/clang/Analysis/PathSensitive/Environment.h b/include/clang/Analysis/PathSensitive/Environment.h index f4d36c3550..b96b1a77b6 100644 --- a/include/clang/Analysis/PathSensitive/Environment.h +++ b/include/clang/Analysis/PathSensitive/Environment.h @@ -41,9 +41,10 @@ private: // Data. BindingsTy ExprBindings; + AnalysisContext *ACtx; - Environment(BindingsTy eb) - : ExprBindings(eb) {} + Environment(BindingsTy eb, AnalysisContext *aCtx) + : ExprBindings(eb), ACtx(aCtx) {} public: typedef BindingsTy::iterator iterator; @@ -57,6 +58,8 @@ public: SVal GetSVal(const Stmt* Ex, ValueManager& ValMgr) const; + AnalysisContext &getAnalysisContext() const { return *ACtx; } + /// Profile - Profile the contents of an Environment object for use /// in a FoldingSet. static void Profile(llvm::FoldingSetNodeID& ID, const Environment* E) { @@ -83,8 +86,8 @@ public: EnvironmentManager(llvm::BumpPtrAllocator& Allocator) : F(Allocator) {} ~EnvironmentManager() {} - Environment getInitialEnvironment() { - return Environment(F.GetEmptyMap()); + Environment getInitialEnvironment(AnalysisContext *ACtx) { + return Environment(F.GetEmptyMap(), ACtx); } Environment BindExpr(Environment Env, const Stmt *S, SVal V, diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 94ef54b731..e44ae86d81 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -67,15 +67,6 @@ template <typename T> struct GRStateTrait { class GRStateManager; -class GRStateContext : public std::pair<GRStateManager*, AnalysisContext*> { -public: - GRStateContext(GRStateManager *Mgr, AnalysisContext *ACtx) - : std::pair<GRStateManager*, AnalysisContext*>(Mgr, ACtx) {} - - GRStateManager *getStateManager() const { return first; } - AnalysisContext *getAnalysisContext() const { return second; } -}; - /// GRState - This class encapsulates the actual data values for /// for a "state" in our symbolic value tracking. It is intended to be /// used as a functional object; that is once it is created and made @@ -90,7 +81,7 @@ private: friend class GRStateManager; - GRStateContext StateCtx; + GRStateManager *StateMgr; Environment Env; Store St; @@ -101,9 +92,9 @@ public: public: /// This ctor is used when creating the first GRState object. - GRState(GRStateManager *mgr, AnalysisContext *actx, const Environment& env, + GRState(GRStateManager *mgr, const Environment& env, Store st, GenericDataMap gdm) - : StateCtx(mgr, actx), + : StateMgr(mgr), Env(env), St(st), GDM(gdm) {} @@ -112,20 +103,20 @@ public: /// in FoldingSetNode will also get copied. GRState(const GRState& RHS) : llvm::FoldingSetNode(), - StateCtx(RHS.StateCtx), + StateMgr(RHS.StateMgr), Env(RHS.Env), St(RHS.St), GDM(RHS.GDM) {} /// getStateManager - Return the GRStateManager associated with this state. GRStateManager &getStateManager() const { - return *StateCtx.getStateManager(); + return *StateMgr; } /// getAnalysisContext - Return the AnalysisContext associated with this /// state. AnalysisContext &getAnalysisContext() const { - return *StateCtx.getAnalysisContext(); + return Env.getAnalysisContext(); } /// getEnvironment - Return the environment associated with this state. diff --git a/lib/Analysis/Environment.cpp b/lib/Analysis/Environment.cpp index 98cd7d8168..0b8ee66f15 100644 --- a/lib/Analysis/Environment.cpp +++ b/lib/Analysis/Environment.cpp @@ -74,12 +74,12 @@ Environment EnvironmentManager::BindExpr(Environment Env, const Stmt *S, if (V.isUnknown()) { if (Invalidate) - return Environment(F.Remove(Env.ExprBindings, S)); + return Environment(F.Remove(Env.ExprBindings, S), Env.ACtx); else return Env; } - return Environment(F.Add(Env.ExprBindings, S, V)); + return Environment(F.Add(Env.ExprBindings, S, V), Env.ACtx); } namespace { @@ -105,12 +105,12 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, const Stmt *S, const GRState *ST, llvm::SmallVectorImpl<const MemRegion*> &DRoots) { - CFG &C = *ST->getAnalysisContext().getCFG(); + CFG &C = *Env.getAnalysisContext().getCFG(); // We construct a new Environment object entirely, as this is cheaper than // individually removing all the subexpression bindings (which will greatly // outnumber block-level expression bindings). - Environment NewEnv = getInitialEnvironment(); + Environment NewEnv = getInitialEnvironment(&Env.getAnalysisContext()); // Iterate over the block-expr bindings. for (Environment::iterator I = Env.begin(), E = Env.end(); diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp index 7bef351006..a2cfdeb96c 100644 --- a/lib/Analysis/GRState.cpp +++ b/lib/Analysis/GRState.cpp @@ -85,22 +85,20 @@ SVal GRState::getSValAsScalarOrLoc(const MemRegion *R) const { } -const GRState *GRState::bindExpr(const Stmt* Ex, SVal V, bool Invalidate) const { - +const GRState *GRState::bindExpr(const Stmt* Ex, SVal V, bool Invalidate) const{ Environment NewEnv = getStateManager().EnvMgr.BindExpr(Env, Ex, V, - Invalidate); - + Invalidate); if (NewEnv == Env) return this; - + GRState NewSt = *this; NewSt.Env = NewEnv; return getStateManager().getPersistentState(NewSt); } const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) { - GRState State(this, InitLoc->getAnalysisContext(), - EnvMgr.getInitialEnvironment(), + GRState State(this, + EnvMgr.getInitialEnvironment(InitLoc->getAnalysisContext()), StoreMgr->getInitialStore(InitLoc), GDMFactory.GetEmptyMap()); |