]> granicus.if.org Git - clang/commitdiff
RegionStoreManager::RemoveDeadBindings() now removes dead 'default' bindings as well.
authorTed Kremenek <kremenek@apple.com>
Sun, 2 Aug 2009 05:00:15 +0000 (05:00 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 2 Aug 2009 05:00:15 +0000 (05:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77875 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 443879a7dd53bf687ac050741864a59bc96188bb..f60b866d65104b499d4f551f0261ca3d5d502dcb 100644 (file)
@@ -127,6 +127,8 @@ public:
   /// 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) {
index c95f6c86f9431194c02db5653c3847c87d397736..32a1dc01759f775511182e7d94c3011c7c3bf90f 100644 (file)
@@ -1763,10 +1763,40 @@ void RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
       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());
 }
 
 //===----------------------------------------------------------------------===//