]> granicus.if.org Git - clang/commitdiff
Generalize the interface of 'StoreManager::RemoveDeadBindings()' to manipulate the...
authorTed Kremenek <kremenek@apple.com>
Sun, 2 Aug 2009 04:45:08 +0000 (04:45 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 2 Aug 2009 04:45:08 +0000 (04:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77870 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/GRState.h
include/clang/Analysis/PathSensitive/Store.h
lib/Analysis/BasicStore.cpp
lib/Analysis/GRState.cpp
lib/Analysis/RegionStore.cpp

index e6e7960869b9a0b34aea62314f435ac653f247c4..443879a7dd53bf687ac050741864a59bc96188bb 100644 (file)
@@ -122,6 +122,8 @@ public:
   ///  is a mapping from locations to values.
   Store getStore() const { return St; }
   
+  void setStore(Store s) { St = s; }
+  
   /// getGDM - Return the generic data map associated with this state.
   GenericDataMap getGDM() const { return GDM; }
   
index 759a80eff4bfdfea2037a9e9f3facf5d9543f076..2d79a19b44e2aa6c66de11acc77d62b2ef0628d1 100644 (file)
@@ -156,8 +156,8 @@ public:
   ///  method returns NULL.
   virtual const MemRegion* getSelfRegion(Store store) = 0;
 
-  virtual Store RemoveDeadBindings(const GRState *state,
-                                   Stmt* Loc, SymbolReaper& SymReaper,
+  virtual void RemoveDeadBindings(GRState &state, Stmt* Loc,
+                                  SymbolReaper& SymReaper,
                       llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0;
 
   virtual const GRState *BindDecl(const GRState *state, const VarDecl *vd, 
index 2b70a964267c660c234fd86b9683d7c22dd9944f..b044d400ae7836646a2baebdbea92e48c7d0038a 100644 (file)
@@ -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) {
index 5728aae3fff8942621ff6c4d6879e33c8ce709dd..dc7c799288ccf440dc3c1128fd9154c64d1e7e2a 100644 (file)
@@ -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);
index 6ca881d73b92f55396cb98d681c526b19e5d3fd7..c95f6c86f9431194c02db5653c3847c87d397736 100644 (file)
@@ -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);
 }
 
 //===----------------------------------------------------------------------===//