diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-08-02 04:45:08 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-08-02 04:45:08 +0000 |
commit | cee28a4c4dd944d11a3336ab8ff782879adde3d0 (patch) | |
tree | 8330f6e56fd6cd07cdf7625bb6bc2498435e633b /clang/lib | |
parent | d45a7860ecbecc3db73d22859918e6e337ae4a53 (diff) | |
download | bcm5719-llvm-cee28a4c4dd944d11a3336ab8ff782879adde3d0.tar.gz bcm5719-llvm-cee28a4c4dd944d11a3336ab8ff782879adde3d0.zip |
Generalize the interface of 'StoreManager::RemoveDeadBindings()' to manipulate the entire GRState, not just the Store.
llvm-svn: 77870
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/BasicStore.cpp | 23 | ||||
-rw-r--r-- | clang/lib/Analysis/GRState.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 15 |
3 files changed, 20 insertions, 21 deletions
diff --git a/clang/lib/Analysis/BasicStore.cpp b/clang/lib/Analysis/BasicStore.cpp index 2b70a964267..b044d400ae7 100644 --- a/clang/lib/Analysis/BasicStore.cpp +++ b/clang/lib/Analysis/BasicStore.cpp @@ -93,10 +93,9 @@ public: const MemRegion* getSelfRegion(Store) { return SelfRegion; } /// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values. - /// It returns a new Store with these values removed. - Store RemoveDeadBindings(const GRState *state, Stmt* Loc, - SymbolReaper& SymReaper, - llvm::SmallVectorImpl<const MemRegion*>& RegionRoots); + /// It updatees the GRState object in place with the values removed. + void RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper, + llvm::SmallVectorImpl<const MemRegion*>& RegionRoots); void iterBindings(Store store, BindingsHandler& f); @@ -379,13 +378,12 @@ Store BasicStoreManager::Remove(Store store, Loc loc) { } } -Store -BasicStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, +void +BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc, SymbolReaper& SymReaper, - llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) -{ - - Store store = state->getStore(); + llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) +{ + Store store = state.getStore(); BindingsTy B = GetBindings(store); typedef SVal::symbol_iterator symbol_iterator; @@ -426,7 +424,7 @@ BasicStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, break; 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. 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) { diff --git a/clang/lib/Analysis/GRState.cpp b/clang/lib/Analysis/GRState.cpp index 5728aae3fff..dc7c799288c 100644 --- a/clang/lib/Analysis/GRState.cpp +++ b/clang/lib/Analysis/GRState.cpp @@ -50,8 +50,7 @@ GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc, state, RegionRoots); // Clean up the store. - NewState.St = StoreMgr->RemoveDeadBindings(&NewState, Loc, SymReaper, - RegionRoots); + StoreMgr->RemoveDeadBindings(NewState, Loc, SymReaper, RegionRoots); return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewState), SymReaper); diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 6ca881d73b9..c95f6c86f94 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -347,7 +347,7 @@ public: /// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values. /// 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); //===------------------------------------------------------------------===// @@ -1630,11 +1630,11 @@ static void UpdateLiveSymbols(SVal X, SymbolReaper& SymReaper) { SymReaper.markLive(*SI); } -Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, - SymbolReaper& SymReaper, +void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc, + SymbolReaper& SymReaper, llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) { - Store store = state->getStore(); + Store store = state.getStore(); RegionBindingsTy B = GetRegionBindings(store); // 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. llvm::OwningPtr<RegionStoreSubRegionMap> - SubRegions(getRegionStoreSubRegionMap(state)); + SubRegions(getRegionStoreSubRegionMap(&state)); // 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. @@ -1657,7 +1657,7 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, } // 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(); I != E; ++I) { const MemRegion *R = I.getKey(); @@ -1765,7 +1765,8 @@ Store RegionStoreManager::RemoveDeadBindings(const GRState *state, Stmt* Loc, // FIXME: remove default bindings as well. - return store; + // Write the store back. + state.setStore(store); } //===----------------------------------------------------------------------===// |