aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/GRState.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-02-19 01:59:33 +0000
committerTed Kremenek <kremenek@apple.com>2011-02-19 01:59:33 +0000
commit77a4d5687c2cb3199c689892c9d040a94ff270af (patch)
tree2de2bb3aebfd7f4c982d64744324c6a486ccd830 /lib/StaticAnalyzer/Core/GRState.cpp
parent7ff07dce18a7c693fe1a15bd7b790d8de9d21e92 (diff)
Add 'StoreRef' smart pointer to allow more fine-grain memory lifetime control of Store objects.
This yields a minor memory reduction (for larger functions) on Sqlite at the cost of slightly higher memory usage on some functions because of the increased size of GRState (which can be optimized). I expect the real memory savings from this enhancement will come when we aggressively canabilize more of the ExplodedGraph. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126012 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/GRState.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/GRState.cpp64
1 files changed, 31 insertions, 33 deletions
diff --git a/lib/StaticAnalyzer/Core/GRState.cpp b/lib/StaticAnalyzer/Core/GRState.cpp
index 80c8bbf195..7defecb366 100644
--- a/lib/StaticAnalyzer/Core/GRState.cpp
+++ b/lib/StaticAnalyzer/Core/GRState.cpp
@@ -53,7 +53,7 @@ GRStateManager::removeDeadBindings(const GRState* state,
state, RegionRoots);
// Clean up the store.
- NewState.St = StoreMgr->removeDeadBindings(NewState.St, LCtx,
+ NewState.St = StoreMgr->removeDeadBindings(NewState.getStore(), LCtx,
SymReaper, RegionRoots);
state = getPersistentState(NewState);
return ConstraintMgr->removeDeadBindings(state, SymReaper);
@@ -73,38 +73,39 @@ const GRState *GRStateManager::MarshalState(const GRState *state,
const GRState *GRState::bindCompoundLiteral(const CompoundLiteralExpr* CL,
const LocationContext *LC,
SVal V) const {
- Store new_store =
- getStateManager().StoreMgr->BindCompoundLiteral(St, CL, LC, V);
- return makeWithStore(new_store);
+ const StoreRef &newStore =
+ getStateManager().StoreMgr->BindCompoundLiteral(getStore(), CL, LC, V);
+ return makeWithStore(newStore);
}
const GRState *GRState::bindDecl(const VarRegion* VR, SVal IVal) const {
- Store new_store = getStateManager().StoreMgr->BindDecl(St, VR, IVal);
- return makeWithStore(new_store);
+ const StoreRef &newStore =
+ getStateManager().StoreMgr->BindDecl(getStore(), VR, IVal);
+ return makeWithStore(newStore);
}
const GRState *GRState::bindDeclWithNoInit(const VarRegion* VR) const {
- Store new_store = getStateManager().StoreMgr->BindDeclWithNoInit(St, VR);
- return makeWithStore(new_store);
+ const StoreRef &newStore =
+ getStateManager().StoreMgr->BindDeclWithNoInit(getStore(), VR);
+ return makeWithStore(newStore);
}
const GRState *GRState::bindLoc(Loc LV, SVal V) const {
GRStateManager &Mgr = getStateManager();
- Store new_store = Mgr.StoreMgr->Bind(St, LV, V);
- const GRState *new_state = makeWithStore(new_store);
-
+ const GRState *newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(),
+ LV, V));
const MemRegion *MR = LV.getAsRegion();
if (MR && Mgr.getOwningEngine())
- return Mgr.getOwningEngine()->processRegionChange(new_state, MR);
+ return Mgr.getOwningEngine()->processRegionChange(newState, MR);
- return new_state;
+ return newState;
}
const GRState *GRState::bindDefault(SVal loc, SVal V) const {
GRStateManager &Mgr = getStateManager();
const MemRegion *R = cast<loc::MemRegionVal>(loc).getRegion();
- Store new_store = Mgr.StoreMgr->BindDefault(St, R, V);
- const GRState *new_state = makeWithStore(new_store);
+ const StoreRef &newStore = Mgr.StoreMgr->BindDefault(getStore(), R, V);
+ const GRState *new_state = makeWithStore(newStore);
return Mgr.getOwningEngine() ?
Mgr.getOwningEngine()->processRegionChange(new_state, R) :
new_state;
@@ -120,39 +121,36 @@ const GRState *GRState::invalidateRegions(const MemRegion * const *Begin,
if (Eng && Eng->wantsRegionChangeUpdate(this)) {
StoreManager::InvalidatedRegions Regions;
-
- Store new_store = Mgr.StoreMgr->invalidateRegions(St, Begin, End,
- E, Count, IS,
- invalidateGlobals,
- &Regions);
- const GRState *new_state = makeWithStore(new_store);
-
- return Eng->processRegionChanges(new_state,
+ const StoreRef &newStore
+ = Mgr.StoreMgr->invalidateRegions(getStore(), Begin, End, E, Count, IS,
+ invalidateGlobals, &Regions);
+ const GRState *newState = makeWithStore(newStore);
+ return Eng->processRegionChanges(newState,
&Regions.front(),
&Regions.back()+1);
}
- Store new_store = Mgr.StoreMgr->invalidateRegions(St, Begin, End,
- E, Count, IS,
- invalidateGlobals,
- NULL);
- return makeWithStore(new_store);
+ const StoreRef &newStore =
+ Mgr.StoreMgr->invalidateRegions(getStore(), Begin, End, E, Count, IS,
+ invalidateGlobals, NULL);
+ return makeWithStore(newStore);
}
const GRState *GRState::unbindLoc(Loc LV) const {
assert(!isa<loc::MemRegionVal>(LV) && "Use invalidateRegion instead.");
Store OldStore = getStore();
- Store NewStore = getStateManager().StoreMgr->Remove(OldStore, LV);
+ const StoreRef &newStore = getStateManager().StoreMgr->Remove(OldStore, LV);
- if (NewStore == OldStore)
+ if (newStore.getStore() == OldStore)
return this;
- return makeWithStore(NewStore);
+ return makeWithStore(newStore);
}
const GRState *GRState::enterStackFrame(const StackFrameContext *frame) const {
- Store new_store = getStateManager().StoreMgr->enterStackFrame(this, frame);
+ const StoreRef &new_store =
+ getStateManager().StoreMgr->enterStackFrame(this, frame);
return makeWithStore(new_store);
}
@@ -323,7 +321,7 @@ const GRState* GRStateManager::getPersistentState(GRState& State) {
return newState;
}
-const GRState* GRState::makeWithStore(Store store) const {
+const GRState* GRState::makeWithStore(const StoreRef &store) const {
GRState NewSt = *this;
NewSt.St = store;
return getStateManager().getPersistentState(NewSt);