Change 'StoreRef' back to 'Store' in GRState, shrinking the size of GRState back by one pointer.

llvm-svn: 126020
This commit is contained in:
Ted Kremenek 2011-02-19 03:56:19 +00:00
parent e9fb6b891e
commit ff6fd0f4b0
3 changed files with 50 additions and 26 deletions

View File

@ -83,7 +83,7 @@ private:
GRStateManager *stateMgr;
Environment Env; // Maps a Stmt to its current SVal.
StoreRef St; // Maps a location to its current value.
Store store; // Maps a location to its current value.
GenericDataMap GDM; // Custom data stored by a client of this class.
unsigned refCount;
@ -91,26 +91,19 @@ private:
/// state with the exception of using the specified Store.
const GRState *makeWithStore(const StoreRef &store) const;
void setStore(const StoreRef &storeRef);
public:
/// This ctor is used when creating the first GRState object.
GRState(GRStateManager *mgr, const Environment& env,
StoreRef st, GenericDataMap gdm)
: stateMgr(mgr),
Env(env),
St(st),
GDM(gdm),
refCount(0) {}
StoreRef st, GenericDataMap gdm);
/// Copy ctor - We must explicitly define this or else the "Next" ptr
/// in FoldingSetNode will also get copied.
GRState(const GRState& RHS)
: llvm::FoldingSetNode(),
stateMgr(RHS.stateMgr),
Env(RHS.Env),
St(RHS.St),
GDM(RHS.GDM),
refCount(0) {}
GRState(const GRState& RHS);
~GRState();
/// Return the GRStateManager associated with this state.
GRStateManager &getStateManager() const { return *stateMgr; }
@ -122,13 +115,10 @@ public:
/// The environment is the mapping from expressions to values.
const Environment& getEnvironment() const { return Env; }
/// getStore - Return the store associated with this state. The store
/// Return the store associated with this state. The store
/// is a mapping from locations to values.
Store getStore() const { return St.getStore(); }
#if 0
void setStore(Store s) { St = s; }
#endif
Store getStore() const { return store; }
/// getGDM - Return the generic data map associated with this state.
GenericDataMap getGDM() const { return GDM; }
@ -140,7 +130,7 @@ public:
/// have the same Environment, Store, and GenericDataMap.
static void Profile(llvm::FoldingSetNodeID& ID, const GRState* V) {
V->Env.Profile(ID);
ID.AddPointer(V->St.getStore());
ID.AddPointer(V->store);
V->GDM.Profile(ID);
}

View File

@ -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;

View File

@ -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.
//===----------------------------------------------------------------------===//