diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExplodedGraph.cpp | 2 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/GRState.cpp | 40 |
2 files changed, 38 insertions, 4 deletions
diff --git a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp index 3ce50d6539..2a8364d411 100644 --- a/lib/StaticAnalyzer/Core/ExplodedGraph.cpp +++ b/lib/StaticAnalyzer/Core/ExplodedGraph.cpp @@ -105,7 +105,7 @@ void ExplodedGraph::reclaimRecentlyAllocatedNodes() { // Conditions 5, 6, and 7. const GRState *state = node->getState(); const GRState *pred_state = pred->getState(); - if (state->St != pred_state->St || state->GDM != pred_state->GDM || + if (state->store != pred_state->store || state->GDM != pred_state->GDM || progPoint.getLocationContext() != pred->getLocationContext()) continue; diff --git a/lib/StaticAnalyzer/Core/GRState.cpp b/lib/StaticAnalyzer/Core/GRState.cpp index 7defecb366..7b216775b8 100644 --- a/lib/StaticAnalyzer/Core/GRState.cpp +++ b/lib/StaticAnalyzer/Core/GRState.cpp @@ -25,6 +25,31 @@ using namespace ento; // FIXME: Move this elsewhere. ConstraintManager::~ConstraintManager() {} +GRState::GRState(GRStateManager *mgr, const Environment& env, + StoreRef st, GenericDataMap gdm) + : stateMgr(mgr), + Env(env), + store(st.getStore()), + GDM(gdm), + refCount(0) { + stateMgr->getStoreManager().incrementReferenceCount(store); +} + +GRState::GRState(const GRState& RHS) + : llvm::FoldingSetNode(), + stateMgr(RHS.stateMgr), + Env(RHS.Env), + store(RHS.store), + GDM(RHS.GDM), + refCount(0) { + stateMgr->getStoreManager().incrementReferenceCount(store); +} + +GRState::~GRState() { + if (store) + stateMgr->getStoreManager().decrementReferenceCount(store); +} + GRStateManager::~GRStateManager() { for (std::vector<GRState::Printer*>::iterator I=Printers.begin(), E=Printers.end(); I!=E; ++I) @@ -53,8 +78,8 @@ GRStateManager::removeDeadBindings(const GRState* state, state, RegionRoots); // Clean up the store. - NewState.St = StoreMgr->removeDeadBindings(NewState.getStore(), LCtx, - SymReaper, RegionRoots); + NewState.setStore(StoreMgr->removeDeadBindings(NewState.getStore(), LCtx, + SymReaper, RegionRoots)); state = getPersistentState(NewState); return ConstraintMgr->removeDeadBindings(state, SymReaper); } @@ -323,10 +348,19 @@ const GRState* GRStateManager::getPersistentState(GRState& State) { const GRState* GRState::makeWithStore(const StoreRef &store) const { GRState NewSt = *this; - NewSt.St = store; + NewSt.setStore(store); return getStateManager().getPersistentState(NewSt); } +void GRState::setStore(const StoreRef &newStore) { + Store newStoreStore = newStore.getStore(); + if (newStoreStore) + stateMgr->getStoreManager().incrementReferenceCount(newStoreStore); + if (store) + stateMgr->getStoreManager().decrementReferenceCount(store); + store = newStoreStore; +} + //===----------------------------------------------------------------------===// // State pretty-printing. //===----------------------------------------------------------------------===// |