From: Ted Kremenek Date: Thu, 18 Jun 2009 01:33:24 +0000 (+0000) Subject: Remove GRStateRef. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47fed90f77a3644b2224d9c34e9bae74d8625332;p=clang Remove GRStateRef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73670 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 9d48831aa8..25863ffd4a 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -184,6 +184,8 @@ public: SVal getSValAsScalarOrLoc(const MemRegion *R) const; + bool scanReachableSymbols(SVal val, SymbolVisitor& visitor) const; + template CB scanReachableSymbols(SVal val) const; // Trait based GDM dispatch. @@ -305,12 +307,9 @@ public: // GRStateManager - Factory object for GRStates. //===----------------------------------------------------------------------===// -class GRStateRef; - class GRStateManager { friend class GRExprEngine; friend class GRState; - friend class GRStateRef; private: EnvironmentManager EnvMgr; @@ -730,9 +729,6 @@ public: void EndPath(const GRState* St) { ConstraintMgr->EndPath(St); } - - bool scanReachableSymbols(SVal val, const GRState* state, - SymbolVisitor& visitor); }; @@ -836,7 +832,7 @@ const GRState *GRState::set(typename GRStateTrait::key_type K, template CB GRState::scanReachableSymbols(SVal val) const { CB cb(this); - Mgr->scanReachableSymbols(val, this, cb); + scanReachableSymbols(val, cb); return cb; } @@ -844,145 +840,6 @@ inline const GRState *GRState::unbindLoc(Loc LV) const { return Mgr->Unbind(this, LV); } -//===----------------------------------------------------------------------===// -// GRStateRef - A "fat" reference to GRState that also bundles GRStateManager. -//===----------------------------------------------------------------------===// - -class GRStateRef { - const GRState* St; - GRStateManager* Mgr; -public: - GRStateRef(const GRState* st, GRStateManager& mgr) : St(st), Mgr(&mgr) {} - - const GRState* getState() const { return St; } - operator const GRState*() const { return St; } - GRStateManager& getManager() const { return *Mgr; } - - SVal GetSVal(Expr* Ex) { - return Mgr->GetSVal(St, Ex); - } - - SVal GetBlkExprSVal(Expr* Ex) { - return Mgr->GetBlkExprSVal(St, Ex); - } - - SVal GetSValAsScalarOrLoc(const Expr *Ex) { - return Mgr->GetSValAsScalarOrLoc(St, Ex); - } - - SVal GetSVal(Loc LV, QualType T = QualType()) { - return Mgr->GetSVal(St, LV, T); - } - - SVal GetSVal(const MemRegion* R) { - return Mgr->GetSVal(St, R); - } - - SVal GetSValAsScalarOrLoc(const MemRegion *R) { - return Mgr->GetSValAsScalarOrLoc(St, R); - } - - GRStateRef BindExpr(Stmt* Ex, SVal V, bool isBlkExpr, bool Invalidate) { - return GRStateRef(Mgr->BindExpr(St, Ex, V, isBlkExpr, Invalidate), *Mgr); - } - - GRStateRef BindExpr(Stmt* Ex, SVal V, bool Invalidate = true) { - return GRStateRef(Mgr->BindExpr(St, Ex, V, Invalidate), *Mgr); - } - - GRStateRef BindDecl(const VarDecl* VD, SVal InitVal) { - return GRStateRef(Mgr->BindDecl(St, VD, InitVal), *Mgr); - } - - GRStateRef BindLoc(Loc LV, SVal V) { - return GRStateRef(Mgr->BindLoc(St, LV, V), *Mgr); - } - - GRStateRef BindLoc(SVal LV, SVal V) { - if (!isa(LV)) return *this; - return BindLoc(cast(LV), V); - } - - GRStateRef Unbind(Loc LV) { - return GRStateRef(Mgr->Unbind(St, LV), *Mgr); - } - - // Trait based GDM dispatch. - template - typename GRStateTrait::data_type get() const { - return St->get(); - } - - template - typename GRStateTrait::lookup_type - get(typename GRStateTrait::key_type key) const { - return St->get(key); - } - - template - GRStateRef set(typename GRStateTrait::data_type D) { - return GRStateRef(Mgr->set(St, D), *Mgr); - } - - template - typename GRStateTrait::context_type get_context() { - return Mgr->get_context(); - } - - template - GRStateRef set(typename GRStateTrait::key_type K, - typename GRStateTrait::value_type E, - typename GRStateTrait::context_type C) { - return GRStateRef(Mgr->set(St, K, E, C), *Mgr); - } - - template - GRStateRef set(typename GRStateTrait::key_type K, - typename GRStateTrait::value_type E) { - return GRStateRef(Mgr->set(St, K, E, get_context()), *Mgr); - } - - template - GRStateRef add(typename GRStateTrait::key_type K) { - return GRStateRef(Mgr->add(St, K, get_context()), *Mgr); - } - - template - GRStateRef remove(typename GRStateTrait::key_type K, - typename GRStateTrait::context_type C) { - return GRStateRef(Mgr->remove(St, K, C), *Mgr); - } - - template - GRStateRef remove(typename GRStateTrait::key_type K) { - return GRStateRef(Mgr->remove(St, K, get_context()), *Mgr); - } - - template - bool contains(typename GRStateTrait::key_type key) const { - return St->contains(key); - } - - // Lvalue methods. - SVal GetLValue(const VarDecl* VD) { - return Mgr->GetLValue(St, VD); - } - - GRStateRef Assume(SVal Cond, bool Assumption, bool& isFeasible) { - return GRStateRef(Mgr->Assume(St, Cond, Assumption, isFeasible), *Mgr); - } - - template - CB scanReachableSymbols(SVal val) { - CB cb(*this); - Mgr->scanReachableSymbols(val, St, cb); - return cb; - } - - SymbolManager& getSymbolManager() { return Mgr->getSymbolManager(); } - BasicValueFactory& getBasicVals() { return Mgr->getBasicVals(); } -}; - } // end clang namespace #endif diff --git a/lib/Analysis/Environment.cpp b/lib/Analysis/Environment.cpp index 2bc071a265..1276cbf1d3 100644 --- a/lib/Analysis/Environment.cpp +++ b/lib/Analysis/Environment.cpp @@ -147,7 +147,7 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, Stmt* Loc, // Mark all symbols in the block expr's value live. MarkLiveCallback cb(SymReaper); - StateMgr.scanReachableSymbols(X, state, cb); + state->scanReachableSymbols(X, cb); } else { // The block expr is dead. SVal X = I.getData(); diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp index ee8cfa43e1..aeb1c04caf 100644 --- a/lib/Analysis/GRState.cpp +++ b/lib/Analysis/GRState.cpp @@ -203,13 +203,13 @@ class VISIBILITY_HIDDEN ScanReachableSymbols : public SubRegionMap::Visitor { typedef llvm::DenseSet VisitedRegionsTy; VisitedRegionsTy visited; - GRStateRef state; + const GRState *state; SymbolVisitor &visitor; llvm::OwningPtr SRM; public: - ScanReachableSymbols(GRStateManager* sm, const GRState *st, SymbolVisitor& v) - : state(st, *sm), visitor(v) {} + ScanReachableSymbols(const GRState *st, SymbolVisitor& v) + : state(st), visitor(v) {} bool scan(nonloc::CompoundVal val); bool scan(SVal val); @@ -260,19 +260,18 @@ bool ScanReachableSymbols::scan(const MemRegion *R) { return false; // Now look at the binding to this region (if any). - if (!scan(state.GetSValAsScalarOrLoc(R))) + if (!scan(state->getSValAsScalarOrLoc(R))) return false; // Now look at the subregions. if (!SRM.get()) - SRM.reset(state.getManager().getStoreManager().getSubRegionMap(state)); + SRM.reset(state->getStateManager().getStoreManager().getSubRegionMap(state)); return SRM->iterSubRegions(R, *this); } -bool GRStateManager::scanReachableSymbols(SVal val, const GRState* state, - SymbolVisitor& visitor) { - ScanReachableSymbols S(this, state, visitor); +bool GRState::scanReachableSymbols(SVal val, SymbolVisitor& visitor) const { + ScanReachableSymbols S(this, visitor); return S.scan(val); }