From: Zhongxing Xu Date: Wed, 26 May 2010 03:27:35 +0000 (+0000) Subject: Remove extents of dead symbolic regions when RemoveDeadBindings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95798981b4859f61c1a3d4df26cb033b3e91518a;p=clang Remove extents of dead symbolic regions when RemoveDeadBindings. 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 --- diff --git a/include/clang/Checker/PathSensitive/Store.h b/include/clang/Checker/PathSensitive/Store.h index 8c6c36daa0..f3155b9aac 100644 --- a/include/clang/Checker/PathSensitive/Store.h +++ b/include/clang/Checker/PathSensitive/Store.h @@ -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& RegionRoots) = 0; virtual Store BindDecl(Store store, const VarRegion *VR, SVal initVal) = 0; diff --git a/lib/Checker/BasicStore.cpp b/lib/Checker/BasicStore.cpp index 34470af29f..5be5ca615e 100644 --- a/lib/Checker/BasicStore.cpp +++ b/lib/Checker/BasicStore.cpp @@ -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& 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& 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, diff --git a/lib/Checker/FlatStore.cpp b/lib/Checker/FlatStore.cpp index 2af9ffa4a4..7f1c579c6e 100644 --- a/lib/Checker/FlatStore.cpp +++ b/lib/Checker/FlatStore.cpp @@ -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& RegionRoots){ - return store; + return StateMgr.getPersistentState(state); } Store BindDecl(Store store, const VarRegion *VR, SVal initVal); diff --git a/lib/Checker/GRState.cpp b/lib/Checker/GRState.cpp index f68e10b0cb..b16e922776 100644 --- a/lib/Checker/GRState.cpp +++ b/lib/Checker/GRState.cpp @@ -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 { diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index 0e4c4439f3..f0b61a4ba3 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -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& 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& 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 Extents =state.get(); + for (llvm::ImmutableMap::iterator I=Extents.begin(), + E = Extents.end(); I != E; ++I) { + if (!W.isVisited(I->first)) + s = s->remove(I->first); + } + return s; }