[cfe-commits] r126020 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h lib/StaticAnalyzer/Core/ExplodedGraph.cpp lib/StaticAnalyzer/Core/GRState.cpp
Ted Kremenek
kremenek at apple.com
Fri Feb 18 19:56:19 PST 2011
Author: kremenek
Date: Fri Feb 18 21:56:19 2011
New Revision: 126020
URL: http://llvm.org/viewvc/llvm-project?rev=126020&view=rev
Log:
Change 'StoreRef' back to 'Store' in GRState, shrinking the size of GRState back by one pointer.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h?rev=126020&r1=126019&r2=126020&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/GRState.h Fri Feb 18 21:56:19 2011
@@ -83,7 +83,7 @@
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 @@
/// 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 @@
/// 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 @@
/// 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);
}
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=126020&r1=126019&r2=126020&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Fri Feb 18 21:56:19 2011
@@ -105,7 +105,7 @@
// 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;
Modified: cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp?rev=126020&r1=126019&r2=126020&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/GRState.cpp Fri Feb 18 21:56:19 2011
@@ -25,6 +25,31 @@
// 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 @@
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* 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.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list