[cfe-commits] r97785 - in /cfe/trunk: include/clang/Checker/PathSensitive/Environment.h include/clang/Checker/PathSensitive/GRState.h include/clang/Checker/PathSensitive/SymbolManager.h lib/Checker/Environment.cpp lib/Checker/GRCoreEngine.cpp lib/Checker/GRExprEngine.cpp lib/Checker/GRState.cpp lib/Checker/SymbolManager.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Thu Mar 4 20:45:36 PST 2010
Author: zhongxingxu
Date: Thu Mar 4 22:45:36 2010
New Revision: 97785
URL: http://llvm.org/viewvc/llvm-project?rev=97785&view=rev
Log:
Remove reference to AnalysisContext in Environment. We already have LocationContext
information in ExplodedNode.
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/Environment.h
cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h
cfe/trunk/lib/Checker/Environment.cpp
cfe/trunk/lib/Checker/GRCoreEngine.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/lib/Checker/GRState.cpp
cfe/trunk/lib/Checker/SymbolManager.cpp
Modified: cfe/trunk/include/clang/Checker/PathSensitive/Environment.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Environment.h?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/Environment.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/Environment.h Thu Mar 4 22:45:36 2010
@@ -26,7 +26,6 @@
namespace clang {
-class AnalysisContext;
class EnvironmentManager;
class ValueManager;
class LiveVariables;
@@ -41,10 +40,9 @@
// Data.
BindingsTy ExprBindings;
- AnalysisContext *ACtx;
- Environment(BindingsTy eb, AnalysisContext *aCtx)
- : ExprBindings(eb), ACtx(aCtx) {}
+ Environment(BindingsTy eb)
+ : ExprBindings(eb) {}
public:
typedef BindingsTy::iterator iterator;
@@ -58,14 +56,10 @@
SVal GetSVal(const Stmt* Ex, ValueManager& ValMgr) const;
- AnalysisContext &getAnalysisContext() const { return *ACtx; }
- void setAnalysisContext(AnalysisContext *ctx) { ACtx = ctx; }
-
/// Profile - Profile the contents of an Environment object for use
/// in a FoldingSet.
static void Profile(llvm::FoldingSetNodeID& ID, const Environment* E) {
E->ExprBindings.Profile(ID);
- ID.AddPointer(E->ACtx);
}
/// Profile - Used to profile the contents of this object for inclusion
@@ -88,8 +82,8 @@
EnvironmentManager(llvm::BumpPtrAllocator& Allocator) : F(Allocator) {}
~EnvironmentManager() {}
- Environment getInitialEnvironment(AnalysisContext *ACtx) {
- return Environment(F.GetEmptyMap(), ACtx);
+ Environment getInitialEnvironment() {
+ return Environment(F.GetEmptyMap());
}
Environment BindExpr(Environment Env, const Stmt *S, SVal V,
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRState.h?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRState.h Thu Mar 4 22:45:36 2010
@@ -109,14 +109,6 @@
return *StateMgr;
}
- /// getAnalysisContext - Return the AnalysisContext associated with this
- /// state.
- AnalysisContext &getAnalysisContext() const {
- return Env.getAnalysisContext();
- }
-
- const GRState *setAnalysisContext(AnalysisContext *ctx) const;
-
/// getEnvironment - Return the environment associated with this state.
/// The environment is the mapping from expressions to values.
const Environment& getEnvironment() const { return Env; }
@@ -338,12 +330,12 @@
};
// Pretty-printing.
- void print(llvm::raw_ostream& Out, const char *nl = "\n",
+ void print(llvm::raw_ostream& Out, CFG &C, const char *nl = "\n",
const char *sep = "") const;
- void printStdErr() const;
+ void printStdErr(CFG &C) const;
- void printDOT(llvm::raw_ostream& Out) const;
+ void printDOT(llvm::raw_ostream& Out, CFG &C) const;
};
class GRStateSet {
Modified: cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h Thu Mar 4 22:45:36 2010
@@ -331,23 +331,20 @@
SetTy TheLiving;
SetTy TheDead;
- LiveVariables& Liveness;
+ const LocationContext *LCtx;
SymbolManager& SymMgr;
- const StackFrameContext *CurrentStackFrame;
public:
- SymbolReaper(LiveVariables& liveness, SymbolManager& symmgr,
- const StackFrameContext *currentStackFrame)
- : Liveness(liveness), SymMgr(symmgr), CurrentStackFrame(currentStackFrame)
- {}
+ SymbolReaper(const LocationContext *ctx, SymbolManager& symmgr)
+ : LCtx(ctx), SymMgr(symmgr) {}
~SymbolReaper() {}
+ const LocationContext *getLocationContext() const { return LCtx; }
+
bool isLive(SymbolRef sym);
- bool isLive(const Stmt* Loc, const Stmt* ExprVal) const {
- return Liveness.isLive(Loc, ExprVal);
- }
+ bool isLive(const Stmt* Loc, const Stmt* ExprVal) const;
bool isLive(const Stmt* Loc, const VarRegion *VR) const;
Modified: cfe/trunk/lib/Checker/Environment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/Environment.cpp?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/Environment.cpp (original)
+++ cfe/trunk/lib/Checker/Environment.cpp Thu Mar 4 22:45:36 2010
@@ -78,12 +78,12 @@
if (V.isUnknown()) {
if (Invalidate)
- return Environment(F.Remove(Env.ExprBindings, S), Env.ACtx);
+ return Environment(F.Remove(Env.ExprBindings, S));
else
return Env;
}
- return Environment(F.Add(Env.ExprBindings, S, V), Env.ACtx);
+ return Environment(F.Add(Env.ExprBindings, S, V));
}
namespace {
@@ -109,12 +109,12 @@
const GRState *ST,
llvm::SmallVectorImpl<const MemRegion*> &DRoots) {
- CFG &C = *Env.getAnalysisContext().getCFG();
+ CFG &C = *SymReaper.getLocationContext()->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(&Env.getAnalysisContext());
+ Environment NewEnv = getInitialEnvironment();
// Iterate over the block-expr bindings.
for (Environment::iterator I = Env.begin(), E = Env.end();
Modified: cfe/trunk/lib/Checker/GRCoreEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCoreEngine.cpp?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRCoreEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRCoreEngine.cpp Thu Mar 4 22:45:36 2010
@@ -682,7 +682,6 @@
// Get the callee's location context.
const StackFrameContext *LocCtx
= cast<StackFrameContext>(Pred->getLocationContext());
- state = state->setAnalysisContext(LocCtx->getParent()->getAnalysisContext());
PostStmt Loc(LocCtx->getCallSite(), LocCtx->getParent());
bool isNew;
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Thu Mar 4 22:45:36 2010
@@ -477,8 +477,9 @@
// Create the cleaned state.
const ExplodedNode *BasePred = Builder->getBasePredecessor();
- SymbolReaper SymReaper(BasePred->getLiveVariables(), SymMgr,
- BasePred->getLocationContext()->getCurrentStackFrame());
+
+ SymbolReaper SymReaper(BasePred->getLocationContext(), SymMgr);
+
CleanedState = AMgr.shouldPurgeDead()
? StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt, SymReaper)
: EntryNode->getState();
@@ -1309,7 +1310,6 @@
const GRState *state = B.getState();
state = getStoreManager().EnterStackFrame(state, LocCtx);
- state = state->setAnalysisContext(LocCtx->getAnalysisContext());
B.GenerateNode(state, LocCtx);
}
@@ -3320,7 +3320,7 @@
Out << "\\|StateID: " << (void*) N->getState() << "\\|";
const GRState *state = N->getState();
- state->printDOT(Out);
+ state->printDOT(Out, *N->getLocationContext()->getCFG());
Out << "\\l";
return Out.str();
Modified: cfe/trunk/lib/Checker/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRState.cpp?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRState.cpp (original)
+++ cfe/trunk/lib/Checker/GRState.cpp Thu Mar 4 22:45:36 2010
@@ -23,12 +23,6 @@
// FIXME: Move this elsewhere.
ConstraintManager::~ConstraintManager() {}
-const GRState *GRState::setAnalysisContext(AnalysisContext *ctx) const {
- GRState NewState = *this;
- NewState.Env.setAnalysisContext(ctx);
- return StateMgr->getPersistentState(NewState);
-}
-
GRStateManager::~GRStateManager() {
for (std::vector<GRState::Printer*>::iterator I=Printers.begin(),
E=Printers.end(); I!=E; ++I)
@@ -105,7 +99,7 @@
const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
GRState State(this,
- EnvMgr.getInitialEnvironment(InitLoc->getAnalysisContext()),
+ EnvMgr.getInitialEnvironment(),
StoreMgr->getInitialStore(InitLoc),
GDMFactory.GetEmptyMap());
@@ -137,14 +131,12 @@
// State pretty-printing.
//===----------------------------------------------------------------------===//
-void GRState::print(llvm::raw_ostream& Out, const char* nl,
+void GRState::print(llvm::raw_ostream& Out, CFG &C, const char* nl,
const char* sep) const {
// Print the store.
GRStateManager &Mgr = getStateManager();
Mgr.getStoreManager().print(getStore(), Out, nl, sep);
- CFG &C = *getAnalysisContext().getCFG();
-
// Print Subexpression bindings.
bool isFirst = true;
@@ -192,12 +184,12 @@
}
}
-void GRState::printDOT(llvm::raw_ostream& Out) const {
- print(Out, "\\l", "\\|");
+void GRState::printDOT(llvm::raw_ostream& Out, CFG &C) const {
+ print(Out, C, "\\l", "\\|");
}
-void GRState::printStdErr() const {
- print(llvm::errs());
+void GRState::printStdErr(CFG &C) const {
+ print(llvm::errs(), C);
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Checker/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SymbolManager.cpp?rev=97785&r1=97784&r2=97785&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Checker/SymbolManager.cpp Thu Mar 4 22:45:36 2010
@@ -215,13 +215,17 @@
return isa<SymbolRegionValue>(sym);
}
+bool SymbolReaper::isLive(const Stmt* Loc, const Stmt* ExprVal) const {
+ return LCtx->getLiveVariables()->isLive(Loc, ExprVal);
+}
+
bool SymbolReaper::isLive(const Stmt *Loc, const VarRegion *VR) const {
const StackFrameContext *SFC = VR->getStackFrame();
- if (SFC == CurrentStackFrame)
- return Liveness.isLive(Loc, VR->getDecl());
+ if (SFC == LCtx->getCurrentStackFrame())
+ return LCtx->getLiveVariables()->isLive(Loc, VR->getDecl());
else
- return SFC->isParentOf(CurrentStackFrame);
+ return SFC->isParentOf(LCtx->getCurrentStackFrame());
}
SymbolVisitor::~SymbolVisitor() {}
More information about the cfe-commits
mailing list