[cfe-commits] r77870 - 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
Sat Aug 1 21:45:08 PDT 2009


Author: kremenek
Date: Sat Aug  1 23:45:08 2009
New Revision: 77870

URL: http://llvm.org/viewvc/llvm-project?rev=77870&view=rev
Log:
Generalize the interface of 'StoreManager::RemoveDeadBindings()' to manipulate the entire GRState, not just the Store.

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=77870&r1=77869&r2=77870&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Sat Aug  1 23:45:08 2009
@@ -122,6 +122,8 @@
   ///  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; }
   

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=77870&r1=77869&r2=77870&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Sat Aug  1 23:45:08 2009
@@ -156,8 +156,8 @@
   ///  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, 

Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=77870&r1=77869&r2=77870&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Sat Aug  1 23:45:08 2009
@@ -93,10 +93,9 @@
   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::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 @@
           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 @@
     }
   }
 
-  return store;
+  // Write the store back.
+  state.setStore(store);
 }
 
 Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl, Store St) {

Modified: cfe/trunk/lib/Analysis/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRState.cpp?rev=77870&r1=77869&r2=77870&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRState.cpp (original)
+++ cfe/trunk/lib/Analysis/GRState.cpp Sat Aug  1 23:45:08 2009
@@ -50,8 +50,7 @@
                                            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);

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=77870&r1=77869&r2=77870&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Sat Aug  1 23:45:08 2009
@@ -347,7 +347,7 @@
   
   /// 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 @@
     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 @@
   
   // 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 @@
   }
   
   // 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 @@
   
   // FIXME: remove default bindings as well.
 
-  return store;
+  // Write the store back.
+  state.setStore(store);
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list