Lazy bingding for region-store manager.
* Now Bind() methods take and return GRState* because binding could
  also alter GDM.
* No variables are initialized except those declared with initial
  values.
* failed C test cases are due to bugs in RemoveDeadBindings(),
which removes constraints that is still alive. This will be fixed in later
patch.
* default value of array and struct regions will be implemented in later patch.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61274 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/SymbolManager.cpp b/lib/Analysis/SymbolManager.cpp
index 1c2814a..746d55c 100644
--- a/lib/Analysis/SymbolManager.cpp
+++ b/lib/Analysis/SymbolManager.cpp
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Analysis/PathSensitive/SymbolManager.h"
+#include "clang/Analysis/PathSensitive/MemRegion.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -21,14 +22,35 @@
   os << getNumber();
 }
 
-SymbolRef SymbolManager::getSymbol(VarDecl* D) {
+SymbolRef SymbolManager::getSymbol(const MemRegion* R) {
+  switch (R->getKind()) {
+  case MemRegion::VarRegionKind:
+    return getSymbol(cast<VarRegion>(R)->getDecl());
+  
+  case MemRegion::ElementRegionKind: {
+    const ElementRegion* ER = cast<ElementRegion>(R);
+    const llvm::APSInt& Idx = 
+      cast<nonloc::ConcreteInt>(ER->getIndex()).getValue();
+    return getElementSymbol(ER->getSuperRegion(), &Idx);
+  }
+
+  case MemRegion::FieldRegionKind: {
+    const FieldRegion* FR = cast<FieldRegion>(R);
+    return getFieldSymbol(FR->getSuperRegion(), FR->getDecl());
+  }
+  default:
+    assert(0 && "unprocessed region");
+  }
+}
+
+SymbolRef SymbolManager::getSymbol(const VarDecl* D) {
 
   assert (isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D) || 
           D->hasGlobalStorage());
   
   llvm::FoldingSetNodeID profile;
   
-  ParmVarDecl* PD = dyn_cast<ParmVarDecl>(D);
+  const ParmVarDecl* PD = dyn_cast<ParmVarDecl>(D);
   
   if (PD)
     SymbolDataParmVar::Profile(profile, PD);