[cfe-commits] r57225 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Oct 6 18:31:05 PDT 2008
Author: zhongxingxu
Date: Mon Oct 6 20:31:04 2008
New Revision: 57225
URL: http://llvm.org/viewvc/llvm-project?rev=57225&view=rev
Log:
Migrate MemRegionManager from StateManager to StoreManager.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
cfe/trunk/lib/Analysis/BasicStore.cpp
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=57225&r1=57224&r2=57225&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Mon Oct 6 20:31:04 2008
@@ -236,7 +236,6 @@
EnvironmentManager EnvMgr;
llvm::OwningPtr<StoreManager> StMgr;
llvm::OwningPtr<ConstraintManager> ConstraintMgr;
- MemRegionManager MRMgr;
GRState::IntSetTy::Factory ISetFactory;
GRState::GenericDataMap::Factory GDMFactory;
@@ -283,9 +282,9 @@
}
// 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 @@
ConstraintManagerCreator CreateConstraintManager,
llvm::BumpPtrAllocator& alloc, CFG& c, LiveVariables& L)
: EnvMgr(alloc),
- MRMgr(alloc),
ISetFactory(alloc),
GDMFactory(alloc),
BasicVals(Ctx, alloc),
@@ -319,7 +317,7 @@
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 @@
// 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.
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=57225&r1=57224&r2=57225&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Mon Oct 6 20:31:04 2008
@@ -29,7 +29,8 @@
class LiveVariables;
class Stmt;
class MemRegion;
-
+class MemRegionManager;
+
class StoreManager {
public:
typedef llvm::SmallSet<SymbolID, 20> LiveSymbolsTy;
@@ -40,7 +41,8 @@
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,
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=57225&r1=57224&r2=57225&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Mon Oct 6 20:31:04 2008
@@ -26,9 +26,11 @@
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 @@
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 @@
virtual void print(Store store, std::ostream& Out,
const char* nl, const char *sep);
-
+
};
} // end anonymous namespace
@@ -164,7 +172,7 @@
// 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 @@
// 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 @@
? 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 @@
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 @@
: cast<RVal>(nonlval::SymbolVal(Sym));
}
- store = SetRVal(store, StateMgr.getLVal(VD), V);
+ store = SetRVal(store, getLVal(VD), V);
}
}
@@ -337,7 +345,7 @@
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());
}
}
More information about the cfe-commits
mailing list