[cfe-commits] r80293 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Environment.h include/clang/Analysis/PathSensitive/GRState.h lib/Analysis/Environment.cpp lib/Analysis/GRState.cpp
Ted Kremenek
kremenek at apple.com
Thu Aug 27 15:15:20 PDT 2009
Author: kremenek
Date: Thu Aug 27 17:15:20 2009
New Revision: 80293
URL: http://llvm.org/viewvc/llvm-project?rev=80293&view=rev
Log:
Move the AnalysisContext* from GRState to Environment.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h
cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
cfe/trunk/lib/Analysis/Environment.cpp
cfe/trunk/lib/Analysis/GRState.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h?rev=80293&r1=80292&r2=80293&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Environment.h Thu Aug 27 17:15:20 2009
@@ -41,9 +41,10 @@
// 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 @@
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 @@
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,
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=80293&r1=80292&r2=80293&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Thu Aug 27 17:15:20 2009
@@ -67,15 +67,6 @@
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 @@
friend class GRStateManager;
- GRStateContext StateCtx;
+ GRStateManager *StateMgr;
Environment Env;
Store St;
@@ -101,9 +92,9 @@
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 @@
/// 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.
Modified: cfe/trunk/lib/Analysis/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Environment.cpp?rev=80293&r1=80292&r2=80293&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/Environment.cpp (original)
+++ cfe/trunk/lib/Analysis/Environment.cpp Thu Aug 27 17:15:20 2009
@@ -74,12 +74,12 @@
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 @@
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();
Modified: cfe/trunk/lib/Analysis/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRState.cpp?rev=80293&r1=80292&r2=80293&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRState.cpp (original)
+++ cfe/trunk/lib/Analysis/GRState.cpp Thu Aug 27 17:15:20 2009
@@ -85,22 +85,20 @@
}
-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());
More information about the cfe-commits
mailing list