Migrate MemRegionManager from StateManager to StoreManager.

llvm-svn: 57225
This commit is contained in:
Zhongxing Xu 2008-10-07 01:31:04 +00:00
parent 7221af384d
commit f5e7c90c46
3 changed files with 29 additions and 21 deletions

View File

@ -236,7 +236,6 @@ private:
EnvironmentManager EnvMgr;
llvm::OwningPtr<StoreManager> StMgr;
llvm::OwningPtr<ConstraintManager> ConstraintMgr;
MemRegionManager MRMgr;
GRState::IntSetTy::Factory ISetFactory;
GRState::GenericDataMap::Factory GDMFactory;
@ -283,9 +282,9 @@ private:
}
// FIXME: Remove when we do lazy initializaton of variable bindings.
const GRState* BindVar(const GRState* St, VarDecl* D, RVal V) {
return SetRVal(St, getLVal(D), V);
}
// const GRState* BindVar(const GRState* St, VarDecl* D, RVal V) {
// return SetRVal(St, getLVal(D), V);
// }
public:
@ -297,7 +296,6 @@ public:
ConstraintManagerCreator CreateConstraintManager,
llvm::BumpPtrAllocator& alloc, CFG& c, LiveVariables& L)
: EnvMgr(alloc),
MRMgr(alloc),
ISetFactory(alloc),
GDMFactory(alloc),
BasicVals(Ctx, alloc),
@ -319,7 +317,7 @@ public:
SymbolManager& getSymbolManager() { return SymMgr; }
LiveVariables& getLiveVariables() { return Liveness; }
llvm::BumpPtrAllocator& getAllocator() { return Alloc; }
MemRegionManager& getRegionManager() { return MRMgr; }
MemRegionManager& getRegionManager() { return StMgr->getRegionManager(); }
typedef StoreManager::DeadSymbolsTy DeadSymbolsTy;
@ -340,11 +338,11 @@ public:
// Utility methods for getting regions.
VarRegion* getRegion(const VarDecl* D) {
return MRMgr.getVarRegion(D);
return getRegionManager().getVarRegion(D);
}
lval::MemRegionVal getLVal(const VarDecl* D) {
return lval::MemRegionVal(getRegion(D));
LVal getLVal(const VarDecl* D) {
return StMgr->getLVal(D);
}
// Methods that query & manipulate the Environment.

View File

@ -29,7 +29,8 @@ class GRStateManager;
class LiveVariables;
class Stmt;
class MemRegion;
class MemRegionManager;
class StoreManager {
public:
typedef llvm::SmallSet<SymbolID, 20> LiveSymbolsTy;
@ -40,7 +41,8 @@ public:
virtual Store SetRVal(Store St, LVal LV, RVal V) = 0;
virtual Store Remove(Store St, LVal LV) = 0;
virtual Store getInitialStore() = 0;
virtual MemRegionManager& getRegionManager() = 0;
virtual LVal getLVal(const VarDecl* VD) = 0;
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,

View File

@ -26,9 +26,11 @@ namespace {
class VISIBILITY_HIDDEN BasicStoreManager : public StoreManager {
VarBindingsTy::Factory VBFactory;
GRStateManager& StateMgr;
MemRegionManager MRMgr;
public:
BasicStoreManager(GRStateManager& mgr) : StateMgr(mgr) {}
BasicStoreManager(GRStateManager& mgr)
: StateMgr(mgr), MRMgr(StateMgr.getAllocator()) {}
virtual ~BasicStoreManager() {}
@ -37,6 +39,12 @@ public:
virtual Store Remove(Store St, LVal LV);
virtual Store getInitialStore();
virtual MemRegionManager& getRegionManager() { return MRMgr; }
virtual LVal getLVal(const VarDecl* VD) {
return lval::MemRegionVal(MRMgr.getVarRegion(VD));
}
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
@ -55,7 +63,7 @@ public:
virtual void print(Store store, std::ostream& Out,
const char* nl, const char *sep);
};
} // end anonymous namespace
@ -164,7 +172,7 @@ BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
// Iterate over the variable bindings.
for (VarBindingsTy::iterator I=B.begin(), E=B.end(); I!=E ; ++I)
if (Liveness.isLive(Loc, I.getKey())) {
RegionRoots.push_back(StateMgr.getRegion(I.getKey()));
RegionRoots.push_back(MRMgr.getVarRegion(I.getKey()));
RVal X = I.getData();
for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI)
@ -198,7 +206,7 @@ BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
// Remove dead variable bindings.
for (VarBindingsTy::iterator I=B.begin(), E=B.end(); I!=E ; ++I) {
const VarRegion* R = cast<VarRegion>(StateMgr.getRegion(I.getKey()));
const VarRegion* R = cast<VarRegion>(MRMgr.getVarRegion(I.getKey()));
if (!Marked.count(R)) {
store = Remove(store, lval::MemRegionVal(R));
@ -240,7 +248,7 @@ Store BasicStoreManager::getInitialStore() {
? RVal::GetSymbolValue(StateMgr.getSymbolManager(), VD)
: UndefinedVal();
St = SetRVal(St, StateMgr.getLVal(VD), X);
St = SetRVal(St, lval::MemRegionVal(MRMgr.getVarRegion(VD)), X);
}
}
}
@ -280,16 +288,16 @@ Store BasicStoreManager::AddDecl(Store store,
if (!Ex) {
QualType T = VD->getType();
if (LVal::IsLValType(T))
store = SetRVal(store, StateMgr.getLVal(VD),
store = SetRVal(store, getLVal(VD),
lval::ConcreteInt(BasicVals.getValue(0, T)));
else if (T->isIntegerType())
store = SetRVal(store, StateMgr.getLVal(VD),
store = SetRVal(store, getLVal(VD),
nonlval::ConcreteInt(BasicVals.getValue(0, T)));
else {
// assert(0 && "ignore other types of variables");
}
} else {
store = SetRVal(store, StateMgr.getLVal(VD), InitVal);
store = SetRVal(store, getLVal(VD), InitVal);
}
}
} else {
@ -307,7 +315,7 @@ Store BasicStoreManager::AddDecl(Store store,
: cast<RVal>(nonlval::SymbolVal(Sym));
}
store = SetRVal(store, StateMgr.getLVal(VD), V);
store = SetRVal(store, getLVal(VD), V);
}
}
@ -337,7 +345,7 @@ void BasicStoreManager::iterBindings(Store store, BindingsHandler& f) {
for (VarBindingsTy::iterator I=B.begin(), E=B.end(); I != E; ++I) {
f.HandleBinding(*this, store, StateMgr.getRegion(I.getKey()),I.getData());
f.HandleBinding(*this, store, MRMgr.getVarRegion(I.getKey()),I.getData());
}
}