Re-apply 68028. The code had drifted enough that the tests would fail without
it.  Will discuss offline whether symbolic regions should by typed or typeless.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68070 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 6094806..0b2d99b 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -362,9 +362,13 @@
     BaseR = cast<loc::MemRegionVal>(BaseL).getRegion();
     break;
 
-  case loc::SymbolValKind:
-    BaseR = MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(&BaseL)->getSymbol());
+  case loc::SymbolValKind: {
+    SymbolRef Sym = cast<loc::SymbolVal>(&BaseL)->getSymbol();
+    const SymbolicRegion* SR = MRMgr.getSymbolicRegion(Sym);
+    // Layer the type information.
+    BaseR = MRMgr.getTypedViewRegion(Sym->getType(getContext()), SR);
     break;
+  }
   
   case loc::GotoLabelKind:
   case loc::FuncValKind:
@@ -407,9 +411,14 @@
 
   const TypedRegion* BaseRegion = 0;
 
-  BaseRegion = isa<loc::SymbolVal>(Base)
-               ? MRMgr.getSymbolicRegion(cast<loc::SymbolVal>(Base).getSymbol())
-               : cast<TypedRegion>(cast<loc::MemRegionVal>(Base).getRegion());
+  if (isa<loc::SymbolVal>(Base)) {
+    SymbolRef Sym = cast<loc::SymbolVal>(Base).getSymbol();
+    SymbolicRegion* SR = MRMgr.getSymbolicRegion(Sym);
+    // Layer the type information.
+    BaseRegion = MRMgr.getTypedViewRegion(Sym->getType(getContext()), SR);
+  } 
+  else
+    BaseRegion = cast<TypedRegion>(cast<loc::MemRegionVal>(Base).getRegion());
 
   // Pointer of any type can be cast and used as array base.
   const ElementRegion *ElemR = dyn_cast<ElementRegion>(BaseRegion);