aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/RegionStore.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-08-02 05:00:15 +0000
committerTed Kremenek <kremenek@apple.com>2009-08-02 05:00:15 +0000
commit093569cfab473e7b461523136a4df30a0473324d (patch)
tree0d9d4d5641ad86f99a21b9a4137cb153ffef1fe1 /lib/Analysis/RegionStore.cpp
parent2f26bc39f3b7bc93b9fdfbb79751b25704e5fdc6 (diff)
RegionStoreManager::RemoveDeadBindings() now removes dead 'default' bindings as well.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionStore.cpp')
-rw-r--r--lib/Analysis/RegionStore.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index c95f6c86f9..32a1dc0175 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -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());
}
//===----------------------------------------------------------------------===//