diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-08-29 00:47:32 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-08-29 00:47:32 +0000 |
commit | 2bc39c61077e6a49728f309bb80a949fb0b2aaff (patch) | |
tree | 5d34c9916057c108fac37e6a6ac817e1f31f0677 /lib/Analysis/BasicStore.cpp | |
parent | 561ca4be84d6456dde1d2bcecf9969d3e99e5368 (diff) |
Added "getBindings" and "BindingAsString" to GRStateManager and StoreManager.
Migrated CFRefCount.cpp to use getBindings and BindingsAsString instead of
making assumptions about the Store (removed dependence on GRState::vb_iterator).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicStore.cpp')
-rw-r--r-- | lib/Analysis/BasicStore.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index ace8f3fbb5..867028dc19 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -56,6 +56,14 @@ public: const char* nl, const char *sep); virtual RegionExtent getExtent(Region R); + + /// getBindings - Returns all bindings in the specified store that bind + /// to the specified symbolic value. + virtual void getBindings(llvm::SmallVectorImpl<store::Binding>& bindings, + Store store, SymbolID Sym); + + /// BindingAsString - Returns a string representing the given binding. + virtual std::string BindingAsString(store::Binding binding); }; } // end anonymous namespace @@ -326,3 +334,29 @@ void BasicStoreManager::print(Store store, std::ostream& Out, I.getData().print(Out); } } + +void +BasicStoreManager::getBindings(llvm::SmallVectorImpl<store::Binding>& bindings, + Store store, SymbolID Sym) { + + VarBindingsTy VB((VarBindingsTy::TreeTy*) store); + + for (VarBindingsTy::iterator I=VB.begin(), E=VB.end(); I!=E; ++I) { + if (const lval::SymbolVal* SV=dyn_cast<lval::SymbolVal>(&I->second)) { + if (SV->getSymbol() == Sym) + bindings.push_back(I->first); + + continue; + } + + if (const nonlval::SymbolVal* SV=dyn_cast<nonlval::SymbolVal>(&I->second)){ + if (SV->getSymbol() == Sym) + bindings.push_back(I->first); + } + } +} + +std::string BasicStoreManager::BindingAsString(store::Binding binding) { + // A binding is just an VarDecl*. + return ((VarDecl*) binding)->getName(); +} |