[cfe-commits] r60570 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp lib/Analysis/GRState.cpp lib/Analysis/RegionStore.cpp
Ted Kremenek
kremenek at apple.com
Thu Dec 4 16:47:55 PST 2008
Author: kremenek
Date: Thu Dec 4 18:47:52 2008
New Revision: 60570
URL: http://llvm.org/viewvc/llvm-project?rev=60570&view=rev
Log:
StoreManager::Retrieve and StoreManager::RemoveDeadBindings now take a GRState* argument instead of a Store. This allows them to use the GDM for storing other data.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/GRState.cpp
cfe/trunk/lib/Analysis/RegionStore.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=60570&r1=60569&r2=60570&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Thu Dec 4 18:47:52 2008
@@ -346,8 +346,8 @@
const CompoundLiteralExpr* CL, SVal V);
const GRState* RemoveDeadBindings(const GRState* St, Stmt* Loc,
- const LiveVariables& Liveness,
- DeadSymbolsTy& DeadSyms);
+ const LiveVariables& Liveness,
+ DeadSymbolsTy& DeadSyms);
const GRState* RemoveSubExprBindings(const GRState* St) {
GRState NewSt = *St;
@@ -459,12 +459,12 @@
}
- SVal GetSVal(const GRState* St, Loc LV, QualType T = QualType()) {
- return StoreMgr->Retrieve(St->getStore(), LV, T);
+ SVal GetSVal(const GRState* state, Loc LV, QualType T = QualType()) {
+ return StoreMgr->Retrieve(state, LV, T);
}
- SVal GetSVal(const GRState* St, const MemRegion* R) {
- return StoreMgr->GetRegionSVal(St->getStore(), R);
+ SVal GetSVal(const GRState* state, const MemRegion* R) {
+ return StoreMgr->GetRegionSVal(state, R);
}
void BindLoc(GRState& St, Loc LV, SVal V) {
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=60570&r1=60569&r2=60570&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Thu Dec 4 18:47:52 2008
@@ -39,10 +39,15 @@
typedef llvm::DenseSet<SymbolID> DeadSymbolsTy;
virtual ~StoreManager() {}
- virtual SVal Retrieve(Store St, Loc LV, QualType T = QualType()) = 0;
-
- virtual SVal GetRegionSVal(Store St, const MemRegion* R) {
- return Retrieve(St, loc::MemRegionVal(R));
+
+ /// Retrieve - Retrieves the value bound to specified location. The optional
+ /// QualType information provides a hint to the store indicating the expected
+ /// type of the returned value.
+ virtual SVal Retrieve(const GRState* state, Loc LV, QualType T=QualType()) =0;
+
+ /// GetRegionSVal - Retrieves the value bound to the specified region.
+ SVal GetRegionSVal(const GRState* state, const MemRegion* R) {
+ return Retrieve(state, loc::MemRegionVal(R));
}
virtual Store Bind(Store St, Loc LV, SVal V) = 0;
@@ -90,7 +95,7 @@
virtual const MemRegion* getSelfRegion(Store store) = 0;
virtual Store
- RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
+ RemoveDeadBindings(const GRState* state, Stmt* Loc, const LiveVariables& Live,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) = 0;
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=60570&r1=60569&r2=60570&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Thu Dec 4 18:47:52 2008
@@ -38,7 +38,7 @@
~BasicStoreManager() {}
- SVal Retrieve(Store St, Loc LV, QualType T);
+ SVal Retrieve(const GRState *state, Loc LV, QualType T);
Store Bind(Store St, Loc LV, SVal V);
Store Remove(Store St, Loc LV);
Store getInitialStore();
@@ -79,10 +79,11 @@
return SelfRegion;
}
- /// RemoveDeadBindings - Scans a BasicStore for dead values. It returns
- /// a new Store with these values removed, and populates LSymbols and
- /// DSymbols with the known set of live and dead symbols respectively.
- Store RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
+ /// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values.
+ /// It returns a new Store with these values removed, and populates LSymbols
+ /// and DSymbols with the known set of live and dead symbols respectively.
+ Store RemoveDeadBindings(const GRState* state, Stmt* Loc,
+ const LiveVariables& Live,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols);
@@ -168,7 +169,7 @@
return Base;
}
-SVal BasicStoreManager::Retrieve(Store St, Loc LV, QualType T) {
+SVal BasicStoreManager::Retrieve(const GRState* state, Loc LV, QualType T) {
if (isa<UnknownVal>(LV))
return UnknownVal();
@@ -183,8 +184,9 @@
if (!R)
return UnknownVal();
-
- VarBindingsTy B(static_cast<const VarBindingsTy::TreeTy*>(St));
+
+ Store store = state->getStore();
+ VarBindingsTy B(static_cast<const VarBindingsTy::TreeTy*>(store));
VarBindingsTy::data_type* T = B.lookup(R->getDecl());
return T ? *T : UnknownVal();
}
@@ -247,11 +249,12 @@
}
Store
-BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
+BasicStoreManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
const LiveVariables& Liveness,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) {
+ Store store = state->getStore();
VarBindingsTy B = GetVarBindings(store);
typedef SVal::symbol_iterator symbol_iterator;
@@ -282,7 +285,7 @@
break;
Marked.insert(R);
- SVal X = GetRegionSVal(store, R);
+ SVal X = GetRegionSVal(state, R);
// FIXME: We need to handle symbols nested in region definitions.
for (symbol_iterator SI=X.symbol_begin(), SE=X.symbol_end(); SI!=SE; ++SI)
Modified: cfe/trunk/lib/Analysis/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRState.cpp?rev=60570&r1=60569&r2=60570&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRState.cpp (original)
+++ cfe/trunk/lib/Analysis/GRState.cpp Thu Dec 4 18:47:52 2008
@@ -33,7 +33,7 @@
}
const GRState*
-GRStateManager::RemoveDeadBindings(const GRState* St, Stmt* Loc,
+GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
const LiveVariables& Liveness,
DeadSymbolsTy& DSymbols) {
@@ -45,17 +45,17 @@
// for optimum performance.
llvm::SmallVector<const MemRegion*, 10> RegionRoots;
StoreManager::LiveSymbolsTy LSymbols;
- GRState NewSt = *St;
+ GRState NewState = *state;
- NewSt.Env =
- EnvMgr.RemoveDeadBindings(NewSt.Env, Loc, Liveness, RegionRoots, LSymbols);
+ NewState.Env = EnvMgr.RemoveDeadBindings(NewState.Env, Loc, Liveness,
+ RegionRoots, LSymbols);
// Clean up the store.
DSymbols.clear();
- NewSt.St = StoreMgr->RemoveDeadBindings(St->getStore(), Loc, Liveness,
- RegionRoots, LSymbols, DSymbols);
+ NewState.St = StoreMgr->RemoveDeadBindings(&NewState, Loc, Liveness,
+ RegionRoots, LSymbols, DSymbols);
- return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewSt),
+ return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewState),
LSymbols, DSymbols);
}
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=60570&r1=60569&r2=60570&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Dec 4 18:47:52 2008
@@ -53,12 +53,12 @@
}
// KillSet GDM stuff.
-typedef llvm::ImmutableSet<const MemRegion*> RegionKillSetTy;
-static int RegionKillSetTyIndex = 0;
+typedef llvm::ImmutableSet<const MemRegion*> RegionKills;
+static int RegionKillsIndex = 0;
namespace clang {
- template<> struct GRStateTrait<RegionKillSetTy>
- : public GRStatePartialTrait<RegionKillSetTy> {
- static void* GDMIndex() { return &RegionKillSetTyIndex; }
+ template<> struct GRStateTrait<RegionKills>
+ : public GRStatePartialTrait<RegionKills> {
+ static void* GDMIndex() { return &RegionKillsIndex; }
};
}
@@ -82,11 +82,6 @@
virtual ~RegionStoreManager() {}
MemRegionManager& getRegionManager() { return MRMgr; }
-
- // FIXME: Is this function necessary?
- SVal GetRegionSVal(Store St, const MemRegion* R) {
- return Retrieve(St, loc::MemRegionVal(R));
- }
Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* CL, SVal V);
@@ -109,7 +104,7 @@
std::pair<const GRState*, SVal>
CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE);
- SVal Retrieve(Store S, Loc L, QualType T = QualType());
+ SVal Retrieve(const GRState* state, Loc L, QualType T = QualType());
Store Bind(Store St, Loc LV, SVal V);
@@ -128,13 +123,14 @@
return 0;
}
- /// RemoveDeadBindings - Scans a RegionStore for dead values. It returns
- /// a new Store with these values removed, and populates LSymbols and
- /// DSymbols with the known set of live and dead symbols respectively.
- Store RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
+ /// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values.
+ /// It returns a new Store with these values removed, and populates LSymbols
+ // and DSymbols with the known set of live and dead symbols respectively.
+ Store RemoveDeadBindings(const GRState* state, Stmt* Loc,
+ const LiveVariables& Live,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols);
-
+
void UpdateLiveSymbols(SVal X, LiveSymbolsTy& LSymbols);
Store BindDecl(Store store, const VarDecl* VD, SVal* InitVal, unsigned Count);
@@ -142,7 +138,7 @@
const GRState* setExtent(const GRState* St, const MemRegion* R, SVal Extent);
static inline RegionBindingsTy GetRegionBindings(Store store) {
- return RegionBindingsTy(static_cast<const RegionBindingsTy::TreeTy*>(store));
+ return RegionBindingsTy(static_cast<const RegionBindingsTy::TreeTy*>(store));
}
void print(Store store, std::ostream& Out, const char* nl, const char *sep);
@@ -393,9 +389,10 @@
return std::make_pair(St, UnknownVal());
}
-SVal RegionStoreManager::Retrieve(Store S, Loc L, QualType T) {
+SVal RegionStoreManager::Retrieve(const GRState* state, Loc L, QualType T) {
assert(!isa<UnknownVal>(L) && "location unknown");
assert(!isa<UndefinedVal>(L) && "location undefined");
+ Store S = state->getStore();
switch (L.getSubKind()) {
case loc::MemRegionKind: {
@@ -626,11 +623,12 @@
LSymbols.insert(*SI);
}
-Store RegionStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
+Store RegionStoreManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
const LiveVariables& Live,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots,
LiveSymbolsTy& LSymbols, DeadSymbolsTy& DSymbols) {
+ Store store = state->getStore();
RegionBindingsTy B = GetRegionBindings(store);
// Lazily constructed backmap from MemRegions to SubRegions.
More information about the cfe-commits
mailing list