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
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index ace8f3f..867028d 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -56,6 +56,14 @@
                      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 @@
     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();
+}