[cfe-commits] r77875 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRState.h lib/Analysis/RegionStore.cpp

Ted Kremenek kremenek at apple.com
Sat Aug 1 22:00:15 PDT 2009


Author: kremenek
Date: Sun Aug  2 00:00:15 2009
New Revision: 77875

URL: http://llvm.org/viewvc/llvm-project?rev=77875&view=rev
Log:
RegionStoreManager::RemoveDeadBindings() now removes dead 'default' bindings as well.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
    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=77875&r1=77874&r2=77875&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Sun Aug  2 00:00:15 2009
@@ -127,6 +127,8 @@
   /// getGDM - Return the generic data map associated with this state.
   GenericDataMap getGDM() const { return GDM; }
   
+  void setGDM(GenericDataMap gdm) { GDM = gdm; }
+  
   /// Profile - Profile the contents of a GRState object for use
   ///  in a FoldingSet.
   static void Profile(llvm::FoldingSetNodeID& ID, const GRState* V) {

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

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Sun Aug  2 00:00:15 2009
@@ -1763,10 +1763,40 @@
       SymReaper.maybeDead(*SI);
   }
   
-  // FIXME: remove default bindings as well.
-
+  // Remove dead 'default' bindings.  
+  RegionDefaultValue::MapTy NewDVM = DVM;
+  RegionDefaultValue::MapTy::Factory &DVMFactory = 
+    state.get_context<RegionDefaultValue>();
+  
+  for (RegionDefaultValue::MapTy::iterator I = DVM.begin(), E = DVM.end();
+       I != E; ++I) {
+    const MemRegion *R = I.getKey();
+    
+    // If this region live?  Is so, none of its symbols are dead.
+    if (Marked.count(R))
+      continue;
+    
+    // Remove this dead region.
+    NewDVM = DVMFactory.Remove(NewDVM, R);
+    
+    // Mark all non-live symbols that this region references as dead.
+    if (const SymbolicRegion* SymR = dyn_cast<SymbolicRegion>(R))
+      SymReaper.maybeDead(SymR->getSymbol());
+    
+    SVal X = I.getData();
+    SVal::symbol_iterator SI = X.symbol_begin(), SE = X.symbol_end();
+    for (; SI != SE; ++SI)
+      SymReaper.maybeDead(*SI);
+  }
+  
   // Write the store back.
   state.setStore(store);
+  
+  // Write the updated default bindings back.
+  // FIXME: Right now this involves a fetching of a persistent state.
+  //  We can do better.
+  if (DVM != NewDVM)
+    state.setGDM(state.set<RegionDefaultValue>(NewDVM)->getGDM());
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list