forked from OSchip/llvm-project
Remove reference to AnalysisContext in Environment. We already have LocationContext
information in ExplodedNode. llvm-svn: 97785
This commit is contained in:
parent
cf67ffa500
commit
e73584384a
|
@ -26,7 +26,6 @@
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
|
||||||
class AnalysisContext;
|
|
||||||
class EnvironmentManager;
|
class EnvironmentManager;
|
||||||
class ValueManager;
|
class ValueManager;
|
||||||
class LiveVariables;
|
class LiveVariables;
|
||||||
|
@ -41,10 +40,9 @@ private:
|
||||||
|
|
||||||
// Data.
|
// Data.
|
||||||
BindingsTy ExprBindings;
|
BindingsTy ExprBindings;
|
||||||
AnalysisContext *ACtx;
|
|
||||||
|
|
||||||
Environment(BindingsTy eb, AnalysisContext *aCtx)
|
Environment(BindingsTy eb)
|
||||||
: ExprBindings(eb), ACtx(aCtx) {}
|
: ExprBindings(eb) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef BindingsTy::iterator iterator;
|
typedef BindingsTy::iterator iterator;
|
||||||
|
@ -58,14 +56,10 @@ public:
|
||||||
|
|
||||||
SVal GetSVal(const Stmt* Ex, ValueManager& ValMgr) const;
|
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
|
/// Profile - Profile the contents of an Environment object for use
|
||||||
/// in a FoldingSet.
|
/// in a FoldingSet.
|
||||||
static void Profile(llvm::FoldingSetNodeID& ID, const Environment* E) {
|
static void Profile(llvm::FoldingSetNodeID& ID, const Environment* E) {
|
||||||
E->ExprBindings.Profile(ID);
|
E->ExprBindings.Profile(ID);
|
||||||
ID.AddPointer(E->ACtx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Profile - Used to profile the contents of this object for inclusion
|
/// Profile - Used to profile the contents of this object for inclusion
|
||||||
|
@ -88,8 +82,8 @@ public:
|
||||||
EnvironmentManager(llvm::BumpPtrAllocator& Allocator) : F(Allocator) {}
|
EnvironmentManager(llvm::BumpPtrAllocator& Allocator) : F(Allocator) {}
|
||||||
~EnvironmentManager() {}
|
~EnvironmentManager() {}
|
||||||
|
|
||||||
Environment getInitialEnvironment(AnalysisContext *ACtx) {
|
Environment getInitialEnvironment() {
|
||||||
return Environment(F.GetEmptyMap(), ACtx);
|
return Environment(F.GetEmptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment BindExpr(Environment Env, const Stmt *S, SVal V,
|
Environment BindExpr(Environment Env, const Stmt *S, SVal V,
|
||||||
|
|
|
@ -109,14 +109,6 @@ public:
|
||||||
return *StateMgr;
|
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.
|
/// getEnvironment - Return the environment associated with this state.
|
||||||
/// The environment is the mapping from expressions to values.
|
/// The environment is the mapping from expressions to values.
|
||||||
const Environment& getEnvironment() const { return Env; }
|
const Environment& getEnvironment() const { return Env; }
|
||||||
|
@ -338,12 +330,12 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Pretty-printing.
|
// 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;
|
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 {
|
class GRStateSet {
|
||||||
|
|
|
@ -331,23 +331,20 @@ class SymbolReaper {
|
||||||
|
|
||||||
SetTy TheLiving;
|
SetTy TheLiving;
|
||||||
SetTy TheDead;
|
SetTy TheDead;
|
||||||
LiveVariables& Liveness;
|
const LocationContext *LCtx;
|
||||||
SymbolManager& SymMgr;
|
SymbolManager& SymMgr;
|
||||||
const StackFrameContext *CurrentStackFrame;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SymbolReaper(LiveVariables& liveness, SymbolManager& symmgr,
|
SymbolReaper(const LocationContext *ctx, SymbolManager& symmgr)
|
||||||
const StackFrameContext *currentStackFrame)
|
: LCtx(ctx), SymMgr(symmgr) {}
|
||||||
: Liveness(liveness), SymMgr(symmgr), CurrentStackFrame(currentStackFrame)
|
|
||||||
{}
|
|
||||||
|
|
||||||
~SymbolReaper() {}
|
~SymbolReaper() {}
|
||||||
|
|
||||||
|
const LocationContext *getLocationContext() const { return LCtx; }
|
||||||
|
|
||||||
bool isLive(SymbolRef sym);
|
bool isLive(SymbolRef sym);
|
||||||
|
|
||||||
bool isLive(const Stmt* Loc, const Stmt* ExprVal) const {
|
bool isLive(const Stmt* Loc, const Stmt* ExprVal) const;
|
||||||
return Liveness.isLive(Loc, ExprVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isLive(const Stmt* Loc, const VarRegion *VR) const;
|
bool isLive(const Stmt* Loc, const VarRegion *VR) const;
|
||||||
|
|
||||||
|
|
|
@ -78,12 +78,12 @@ Environment EnvironmentManager::BindExpr(Environment Env, const Stmt *S,
|
||||||
|
|
||||||
if (V.isUnknown()) {
|
if (V.isUnknown()) {
|
||||||
if (Invalidate)
|
if (Invalidate)
|
||||||
return Environment(F.Remove(Env.ExprBindings, S), Env.ACtx);
|
return Environment(F.Remove(Env.ExprBindings, S));
|
||||||
else
|
else
|
||||||
return Env;
|
return Env;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Environment(F.Add(Env.ExprBindings, S, V), Env.ACtx);
|
return Environment(F.Add(Env.ExprBindings, S, V));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -109,12 +109,12 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, const Stmt *S,
|
||||||
const GRState *ST,
|
const GRState *ST,
|
||||||
llvm::SmallVectorImpl<const MemRegion*> &DRoots) {
|
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
|
// We construct a new Environment object entirely, as this is cheaper than
|
||||||
// individually removing all the subexpression bindings (which will greatly
|
// individually removing all the subexpression bindings (which will greatly
|
||||||
// outnumber block-level expression bindings).
|
// outnumber block-level expression bindings).
|
||||||
Environment NewEnv = getInitialEnvironment(&Env.getAnalysisContext());
|
Environment NewEnv = getInitialEnvironment();
|
||||||
|
|
||||||
// Iterate over the block-expr bindings.
|
// Iterate over the block-expr bindings.
|
||||||
for (Environment::iterator I = Env.begin(), E = Env.end();
|
for (Environment::iterator I = Env.begin(), E = Env.end();
|
||||||
|
|
|
@ -682,7 +682,6 @@ void GRCallExitNodeBuilder::GenerateNode(const GRState *state) {
|
||||||
// Get the callee's location context.
|
// Get the callee's location context.
|
||||||
const StackFrameContext *LocCtx
|
const StackFrameContext *LocCtx
|
||||||
= cast<StackFrameContext>(Pred->getLocationContext());
|
= cast<StackFrameContext>(Pred->getLocationContext());
|
||||||
state = state->setAnalysisContext(LocCtx->getParent()->getAnalysisContext());
|
|
||||||
|
|
||||||
PostStmt Loc(LocCtx->getCallSite(), LocCtx->getParent());
|
PostStmt Loc(LocCtx->getCallSite(), LocCtx->getParent());
|
||||||
bool isNew;
|
bool isNew;
|
||||||
|
|
|
@ -477,8 +477,9 @@ void GRExprEngine::ProcessStmt(CFGElement CE, GRStmtNodeBuilder& builder) {
|
||||||
|
|
||||||
// Create the cleaned state.
|
// Create the cleaned state.
|
||||||
const ExplodedNode *BasePred = Builder->getBasePredecessor();
|
const ExplodedNode *BasePred = Builder->getBasePredecessor();
|
||||||
SymbolReaper SymReaper(BasePred->getLiveVariables(), SymMgr,
|
|
||||||
BasePred->getLocationContext()->getCurrentStackFrame());
|
SymbolReaper SymReaper(BasePred->getLocationContext(), SymMgr);
|
||||||
|
|
||||||
CleanedState = AMgr.shouldPurgeDead()
|
CleanedState = AMgr.shouldPurgeDead()
|
||||||
? StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt, SymReaper)
|
? StateMgr.RemoveDeadBindings(EntryNode->getState(), CurrentStmt, SymReaper)
|
||||||
: EntryNode->getState();
|
: EntryNode->getState();
|
||||||
|
@ -1309,7 +1310,6 @@ void GRExprEngine::ProcessCallEnter(GRCallEnterNodeBuilder &B) {
|
||||||
|
|
||||||
const GRState *state = B.getState();
|
const GRState *state = B.getState();
|
||||||
state = getStoreManager().EnterStackFrame(state, LocCtx);
|
state = getStoreManager().EnterStackFrame(state, LocCtx);
|
||||||
state = state->setAnalysisContext(LocCtx->getAnalysisContext());
|
|
||||||
|
|
||||||
B.GenerateNode(state, LocCtx);
|
B.GenerateNode(state, LocCtx);
|
||||||
}
|
}
|
||||||
|
@ -3320,7 +3320,7 @@ struct DOTGraphTraits<ExplodedNode*> :
|
||||||
Out << "\\|StateID: " << (void*) N->getState() << "\\|";
|
Out << "\\|StateID: " << (void*) N->getState() << "\\|";
|
||||||
|
|
||||||
const GRState *state = N->getState();
|
const GRState *state = N->getState();
|
||||||
state->printDOT(Out);
|
state->printDOT(Out, *N->getLocationContext()->getCFG());
|
||||||
|
|
||||||
Out << "\\l";
|
Out << "\\l";
|
||||||
return Out.str();
|
return Out.str();
|
||||||
|
|
|
@ -23,12 +23,6 @@ using namespace clang;
|
||||||
// FIXME: Move this elsewhere.
|
// FIXME: Move this elsewhere.
|
||||||
ConstraintManager::~ConstraintManager() {}
|
ConstraintManager::~ConstraintManager() {}
|
||||||
|
|
||||||
const GRState *GRState::setAnalysisContext(AnalysisContext *ctx) const {
|
|
||||||
GRState NewState = *this;
|
|
||||||
NewState.Env.setAnalysisContext(ctx);
|
|
||||||
return StateMgr->getPersistentState(NewState);
|
|
||||||
}
|
|
||||||
|
|
||||||
GRStateManager::~GRStateManager() {
|
GRStateManager::~GRStateManager() {
|
||||||
for (std::vector<GRState::Printer*>::iterator I=Printers.begin(),
|
for (std::vector<GRState::Printer*>::iterator I=Printers.begin(),
|
||||||
E=Printers.end(); I!=E; ++I)
|
E=Printers.end(); I!=E; ++I)
|
||||||
|
@ -105,7 +99,7 @@ const GRState *GRState::BindExpr(const Stmt* Ex, SVal V, bool Invalidate) const{
|
||||||
|
|
||||||
const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
|
const GRState* GRStateManager::getInitialState(const LocationContext *InitLoc) {
|
||||||
GRState State(this,
|
GRState State(this,
|
||||||
EnvMgr.getInitialEnvironment(InitLoc->getAnalysisContext()),
|
EnvMgr.getInitialEnvironment(),
|
||||||
StoreMgr->getInitialStore(InitLoc),
|
StoreMgr->getInitialStore(InitLoc),
|
||||||
GDMFactory.GetEmptyMap());
|
GDMFactory.GetEmptyMap());
|
||||||
|
|
||||||
|
@ -137,14 +131,12 @@ const GRState* GRState::makeWithStore(Store store) const {
|
||||||
// State pretty-printing.
|
// 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 {
|
const char* sep) const {
|
||||||
// Print the store.
|
// Print the store.
|
||||||
GRStateManager &Mgr = getStateManager();
|
GRStateManager &Mgr = getStateManager();
|
||||||
Mgr.getStoreManager().print(getStore(), Out, nl, sep);
|
Mgr.getStoreManager().print(getStore(), Out, nl, sep);
|
||||||
|
|
||||||
CFG &C = *getAnalysisContext().getCFG();
|
|
||||||
|
|
||||||
// Print Subexpression bindings.
|
// Print Subexpression bindings.
|
||||||
bool isFirst = true;
|
bool isFirst = true;
|
||||||
|
|
||||||
|
@ -192,12 +184,12 @@ void GRState::print(llvm::raw_ostream& Out, const char* nl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRState::printDOT(llvm::raw_ostream& Out) const {
|
void GRState::printDOT(llvm::raw_ostream& Out, CFG &C) const {
|
||||||
print(Out, "\\l", "\\|");
|
print(Out, C, "\\l", "\\|");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRState::printStdErr() const {
|
void GRState::printStdErr(CFG &C) const {
|
||||||
print(llvm::errs());
|
print(llvm::errs(), C);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -215,13 +215,17 @@ bool SymbolReaper::isLive(SymbolRef sym) {
|
||||||
return isa<SymbolRegionValue>(sym);
|
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 {
|
bool SymbolReaper::isLive(const Stmt *Loc, const VarRegion *VR) const {
|
||||||
const StackFrameContext *SFC = VR->getStackFrame();
|
const StackFrameContext *SFC = VR->getStackFrame();
|
||||||
|
|
||||||
if (SFC == CurrentStackFrame)
|
if (SFC == LCtx->getCurrentStackFrame())
|
||||||
return Liveness.isLive(Loc, VR->getDecl());
|
return LCtx->getLiveVariables()->isLive(Loc, VR->getDecl());
|
||||||
else
|
else
|
||||||
return SFC->isParentOf(CurrentStackFrame);
|
return SFC->isParentOf(LCtx->getCurrentStackFrame());
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolVisitor::~SymbolVisitor() {}
|
SymbolVisitor::~SymbolVisitor() {}
|
||||||
|
|
Loading…
Reference in New Issue