]> granicus.if.org Git - clang/commitdiff
Remove extents of dead symbolic regions when RemoveDeadBindings.
authorZhongxing Xu <xuzhongxing@gmail.com>
Wed, 26 May 2010 03:27:35 +0000 (03:27 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Wed, 26 May 2010 03:27:35 +0000 (03:27 +0000)
This requires creating new persistent states due to the nature of GDM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104668 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 8c6c36daa0a263432c970868edd41f03ac843cb1..f3155b9aacd48b236f4423d5fd17466957704f52 100644 (file)
@@ -144,9 +144,9 @@ public:
     return UnknownVal();
   }
 
-  virtual Store RemoveDeadBindings(Store store, Stmt* Loc,
-                                   const StackFrameContext *LCtx,
-                                   SymbolReaper& SymReaper,
+  virtual const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc,
+                                            const StackFrameContext *LCtx,
+                                            SymbolReaper& SymReaper,
                       llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0;
 
   virtual Store BindDecl(Store store, const VarRegion *VR, SVal initVal) = 0;
index 34470af29f4a0a56e630f5d34627d2d343424ccf..5be5ca615ed6b48a2c5609365ec8e08f1e409412 100644 (file)
@@ -72,7 +72,7 @@ public:
 
   /// RemoveDeadBindings - Scans a BasicStore of 'state' for dead values.
   ///  It updatees the GRState object in place with the values removed.
-  Store RemoveDeadBindings(Store store, Stmt* Loc, 
+  const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc, 
                            const StackFrameContext *LCtx,
                            SymbolReaper& SymReaper,
                           llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
@@ -251,11 +251,12 @@ Store BasicStoreManager::Remove(Store store, Loc loc) {
   }
 }
 
-Store BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
+const GRState *BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
                                             const StackFrameContext *LCtx,
                                             SymbolReaper& SymReaper,
                            llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
 {
+  Store store = state.getStore();
   BindingsTy B = GetBindings(store);
   typedef SVal::symbol_iterator symbol_iterator;
 
@@ -329,7 +330,8 @@ Store BasicStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
     }
   }
 
-  return store;
+  state.setStore(store);
+  return StateMgr.getPersistentState(state);
 }
 
 Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl,
index 2af9ffa4a4d9a21b0f1d238bf569507da5ff4a76..7f1c579c6edb742c1373d33db38c508ab60d980f 100644 (file)
@@ -44,11 +44,11 @@ public:
   }
 
   SVal ArrayToPointer(Loc Array);
-  Store RemoveDeadBindings(Store store, Stmt* Loc, 
+  const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc, 
                            const StackFrameContext *LCtx,
                            SymbolReaper& SymReaper,
                          llvm::SmallVectorImpl<const MemRegion*>& RegionRoots){
-    return store;
+    return StateMgr.getPersistentState(state);
   }
 
   Store BindDecl(Store store, const VarRegion *VR, SVal initVal);
index f68e10b0cbc9bd5f9cbdec0591c5d6cf6954f311..b16e922776e53c6f1b9180cb2fb404c698a4bca5 100644 (file)
@@ -51,11 +51,10 @@ GRStateManager::RemoveDeadBindings(const GRState* state, Stmt* Loc,
                                            state, RegionRoots);
 
   // Clean up the store.
-  NewState.St = StoreMgr->RemoveDeadBindings(NewState.St, Loc, LCtx, SymReaper
-                                             RegionRoots);
+  const GRState *s = StoreMgr->RemoveDeadBindings(NewState, Loc, LCtx
+                                                  SymReaper, RegionRoots);
 
-  return ConstraintMgr->RemoveDeadBindings(getPersistentState(NewState),
-                                           SymReaper);
+  return ConstraintMgr->RemoveDeadBindings(s, SymReaper);
 }
 
 const GRState *GRState::unbindLoc(Loc LV) const {
index 0e4c4439f34da593866ff53b748b6b3c3656b304..f0b61a4ba3f2bd092b714048c65822326df3779b 100644 (file)
@@ -352,9 +352,9 @@ public: // Part of public interface to class.
 
   /// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values.
   ///  It returns a new Store with these values removed.
-  Store RemoveDeadBindings(Store store, Stmt* Loc, 
-                           const StackFrameContext *LCtx,
-                           SymbolReaper& SymReaper,
+  const GRState *RemoveDeadBindings(GRState &state, Stmt* Loc, 
+                                    const StackFrameContext *LCtx,
+                                    SymbolReaper& SymReaper,
                           llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
 
   const GRState *EnterStackFrame(const GRState *state,
@@ -1822,12 +1822,12 @@ bool RemoveDeadBindingsWorker::UpdatePostponed() {
   return changed;
 }
 
-Store RegionStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
+const GRState *RegionStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
                                              const StackFrameContext *LCtx,
                                              SymbolReaper& SymReaper,
                            llvm::SmallVectorImpl<const MemRegion*>& RegionRoots)
 {
-  RegionBindings B = GetRegionBindings(store);
+  RegionBindings B = GetRegionBindings(state.getStore());
   RemoveDeadBindingsWorker W(*this, StateMgr, B, SymReaper, Loc, LCtx);
   W.GenerateClusters();
 
@@ -1860,8 +1860,16 @@ Store RegionStoreManager::RemoveDeadBindings(Store store, Stmt* Loc,
     for (; SI != SE; ++SI)
       SymReaper.maybeDead(*SI);
   }
-
-  return B.getRoot();
+  state.setStore(B.getRoot());
+  const GRState *s = StateMgr.getPersistentState(state);
+  // Remove the extents of dead symbolic regions.
+  llvm::ImmutableMap<const MemRegion*,SVal> Extents =state.get<RegionExtents>();
+  for (llvm::ImmutableMap<const MemRegion *, SVal>::iterator I=Extents.begin(),
+         E = Extents.end(); I != E; ++I) {
+    if (!W.isVisited(I->first))
+      s = s->remove<RegionExtents>(I->first);
+  }
+  return s;
 }