Generalize the interface of 'StoreManager::RemoveDeadBindings()' to manipulate the entire GRState, not just the Store.

llvm-svn: 77870
This commit is contained in:
Ted Kremenek 2009-08-02 04:45:08 +00:00
parent d45a7860ec
commit cee28a4c4d
5 changed files with 24 additions and 23 deletions

View File

@ -122,6 +122,8 @@ public:
/// is a mapping from locations to values. /// is a mapping from locations to values.
Store getStore() const { return St; } Store getStore() const { return St; }
void setStore(Store s) { St = s; }
/// getGDM - Return the generic data map associated with this state. /// getGDM - Return the generic data map associated with this state.
GenericDataMap getGDM() const { return GDM; } GenericDataMap getGDM() const { return GDM; }

View File

@ -156,8 +156,8 @@ public:
/// method returns NULL. /// method returns NULL.
virtual const MemRegion* getSelfRegion(Store store) = 0; virtual const MemRegion* getSelfRegion(Store store) = 0;
virtual Store RemoveDeadBindings(const GRState *state, virtual void RemoveDeadBindings(GRState &state, Stmt* Loc,
Stmt* Loc, SymbolReaper& SymReaper, SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0; llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0;
virtual const GRState *BindDecl(const GRState *state, const VarDecl *vd, virtual const GRState *BindDecl(const GRState *state, const VarDecl *vd,

View File

@ -93,10 +93,9 @@ public:
const MemRegion* getSelfRegion(Store) { return SelfRegion; } const MemRegion* getSelfRegion(Store) { return SelfRegion; }
/// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values. /// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values.
/// It returns a new Store with these values removed. /// It updatees the GRState object in place with the values removed.
Store RemoveDeadBindings(const GRState *state, Stmt* Loc, void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper,
SymbolReaper& SymReaper, llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
void iterBindings(Store store, BindingsHandler& f); void iterBindings(Store store, BindingsHandler& f);
@ -379,13 +378,12 @@ Store BasicStoreManager::Remove(Store store, Loc loc) {
} }
} }
Store void
BasicStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper, SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
{ {
Store store = state.getStore();
Store store = state->getStore();
BindingsTy B = GetBindings(store); BindingsTy B = GetBindings(store);
typedef SVal::symbol_iterator symbol_iterator; typedef SVal::symbol_iterator symbol_iterator;
@ -426,7 +424,7 @@ BasicStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc,
break; break;
Marked.insert(MR); Marked.insert(MR);
SVal X = Retrieve(state, loc::MemRegionVal(MR)).getSVal(); SVal X = Retrieve(&state, loc::MemRegionVal(MR)).getSVal();
// FIXME: We need to handle symbols nested in region definitions. // FIXME: We need to handle symbols nested in region definitions.
for (symbol_iterator SI=X.symbol_begin(),SE=X.symbol_end();SI!=SE;++SI) for (symbol_iterator SI=X.symbol_begin(),SE=X.symbol_end();SI!=SE;++SI)
@ -459,7 +457,8 @@ BasicStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc,
} }
} }
return store; // Write the store back.
state.setStore(store);
} }
Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl, Store St) { Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl, Store St) {

View File

@ -50,8 +50,7 @@ GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
state, RegionRoots); state, RegionRoots);
// Clean up the store. // Clean up the store.
NewState.St = StoreMgr->RemoveDeadBindings(&NewState, Loc, SymReaper, StoreMgr->RemoveDeadBindings(NewState, Loc, SymReaper, RegionRoots);
RegionRoots);
return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewState), return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewState),
SymReaper); SymReaper);

View File

@ -347,7 +347,7 @@ public:
/// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values. /// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values.
/// It returns a new Store with these values removed. /// It returns a new Store with these values removed.
Store RemoveDeadBindings(const GRState *state, Stmt* Loc, SymbolReaper& SymReaper, void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots); llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
//===------------------------------------------------------------------===// //===------------------------------------------------------------------===//
@ -1630,11 +1630,11 @@ static void UpdateLiveSymbols(SVal X, SymbolReaper& SymReaper) {
SymReaper.markLive(*SI); SymReaper.markLive(*SI);
} }
Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
SymbolReaper& SymReaper, SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
{ {
Store store = state->getStore(); Store store = state.getStore();
RegionBindingsTy B = GetRegionBindings(store); RegionBindingsTy B = GetRegionBindings(store);
// Lazily constructed backmap from MemRegions to SubRegions. // Lazily constructed backmap from MemRegions to SubRegions.
@ -1643,7 +1643,7 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc,
// The backmap from regions to subregions. // The backmap from regions to subregions.
llvm::OwningPtr<RegionStoreSubRegionMap> llvm::OwningPtr<RegionStoreSubRegionMap>
SubRegions(getRegionStoreSubRegionMap(state)); SubRegions(getRegionStoreSubRegionMap(&state));
// Do a pass over the regions in the store. For VarRegions we check if // Do a pass over the regions in the store. For VarRegions we check if
// the variable is still live and if so add it to the list of live roots. // the variable is still live and if so add it to the list of live roots.
@ -1657,7 +1657,7 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc,
} }
// Scan the default bindings for "intermediate" roots. // Scan the default bindings for "intermediate" roots.
RegionDefaultValue::MapTy DVM = state->get<RegionDefaultValue>(); RegionDefaultValue::MapTy DVM = state.get<RegionDefaultValue>();
for (RegionDefaultValue::MapTy::iterator I = DVM.begin(), E = DVM.end(); for (RegionDefaultValue::MapTy::iterator I = DVM.begin(), E = DVM.end();
I != E; ++I) { I != E; ++I) {
const MemRegion *R = I.getKey(); const MemRegion *R = I.getKey();
@ -1765,7 +1765,8 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc,
// FIXME: remove default bindings as well. // FIXME: remove default bindings as well.
return store; // Write the store back.
state.setStore(store);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//