[cfe-commits] r73667 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRState.h lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Wed Jun 17 17:49:02 PDT 2009
Author: kremenek
Date: Wed Jun 17 19:49:02 2009
New Revision: 73667
URL: http://llvm.org/viewvc/llvm-project?rev=73667&view=rev
Log:
Remove another dependency on GRStateRef.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=73667&r1=73666&r2=73667&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Wed Jun 17 19:49:02 2009
@@ -158,6 +158,10 @@
BasicValueFactory &getBasicVals() const;
SymbolManager &getSymbolManager() const;
+
+ const GRState *bind(Loc location, SVal V) const;
+
+ const GRState *bind(SVal location, SVal V) const;
SVal getLValue(const VarDecl* VD) const;
@@ -173,6 +177,8 @@
SVal getSValAsScalarOrLoc(const MemRegion *R) const;
+ template <typename CB> CB scanReachableSymbols(SVal val) const;
+
// Trait based GDM dispatch.
void* const* FindGDM(void* K) const;
@@ -195,6 +201,14 @@
template <typename T>
typename GRStateTrait<T>::context_type get_context() const;
+
+ template<typename T>
+ const GRState *remove(typename GRStateTrait<T>::key_type K) const;
+
+ template<typename T>
+ const GRState *remove(typename GRStateTrait<T>::key_type K,
+ typename GRStateTrait<T>::context_type C) const;
+
template<typename T>
const GRState *set(typename GRStateTrait<T>::data_type D) const;
@@ -717,6 +731,14 @@
// Out-of-line method definitions for GRState.
//===----------------------------------------------------------------------===//
+inline const GRState *GRState::bind(Loc LV, SVal V) const {
+ return Mgr->BindLoc(this, LV, V);
+}
+
+inline const GRState *GRState::bind(SVal LV, SVal V) const {
+ return !isa<Loc>(LV) ? this : bind(cast<Loc>(LV), V);
+}
+
inline SVal GRState::getLValue(const VarDecl* VD) const {
return Mgr->GetLValue(this, VD);
}
@@ -764,6 +786,17 @@
}
template<typename T>
+const GRState *GRState::remove(typename GRStateTrait<T>::key_type K) const {
+ return Mgr->remove<T>(this, K, get_context<T>());
+}
+
+template<typename T>
+const GRState *GRState::remove(typename GRStateTrait<T>::key_type K,
+ typename GRStateTrait<T>::context_type C) const {
+ return Mgr->remove<T>(this, K, C);
+}
+
+template<typename T>
const GRState *GRState::set(typename GRStateTrait<T>::data_type D) const {
return Mgr->set<T>(this, D);
}
@@ -780,6 +813,13 @@
typename GRStateTrait<T>::context_type C) const {
return Mgr->set<T>(this, K, E, C);
}
+
+template <typename CB>
+CB GRState::scanReachableSymbols(SVal val) const {
+ CB cb(this);
+ Mgr->scanReachableSymbols(val, this, cb);
+ return cb;
+}
//===----------------------------------------------------------------------===//
// GRStateRef - A "fat" reference to GRState that also bundles GRStateManager.
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=73667&r1=73666&r2=73667&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Wed Jun 17 19:49:02 2009
@@ -3114,17 +3114,15 @@
namespace {
class VISIBILITY_HIDDEN StopTrackingCallback : public SymbolVisitor {
- GRStateRef state;
+ const GRState *state;
public:
- StopTrackingCallback(GRStateRef st) : state(st) {}
- GRStateRef getState() { return state; }
+ StopTrackingCallback(const GRState *st) : state(st) {}
+ const GRState *getState() const { return state; }
bool VisitSymbol(SymbolRef sym) {
- state = state.remove<RefBindings>(sym);
+ state = state->remove<RefBindings>(sym);
return true;
}
-
- const GRState* getState() const { return state.getState(); }
};
} // end anonymous namespace
@@ -3139,7 +3137,7 @@
// (2) we are binding to a memregion that does not have stack storage
// (3) we are binding to a memregion with stack storage that the store
// does not understand.
- GRStateRef state = B.getState();
+ const GRState *state = B.getState();
if (!isa<loc::MemRegionVal>(location))
escapes = true;
@@ -3151,7 +3149,7 @@
// To test (3), generate a new state with the binding removed. If it is
// the same state, then it escapes (since the store cannot represent
// the binding).
- escapes = (state == (state.BindLoc(cast<Loc>(location), UnknownVal())));
+ escapes = (state == (state->bind(cast<Loc>(location), UnknownVal())));
}
}
@@ -3163,10 +3161,9 @@
// Otherwise, find all symbols referenced by 'val' that we are tracking
// and stop tracking them.
- B.MakeNode(state.scanReachableSymbols<StopTrackingCallback>(val).getState());
+ B.MakeNode(state->scanReachableSymbols<StopTrackingCallback>(val).getState());
}
-
// Return statements.
void CFRefCount::EvalReturn(ExplodedNodeSet<GRState>& Dst,
More information about the cfe-commits
mailing list