RegionStore:
-refactor logic for retrieving bindings from VarDecls into
 RegionStoreManager::RetrieveVar()
- improve RegionStoreManager::CastRetrievedVal() and SimpleSValuate::EvalCastNL
  to better handle casts of values of the same canonical type as well as
  casts of LocAsInteger values.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76516 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/SimpleSValuator.cpp b/lib/Analysis/SimpleSValuator.cpp
index 4f8c29c..7462fe6 100644
--- a/lib/Analysis/SimpleSValuator.cpp
+++ b/lib/Analysis/SimpleSValuator.cpp
@@ -48,9 +48,27 @@
   
   bool isLocType = Loc::IsLocType(castTy);
   
-  if (isLocType)
-    if (nonloc::LocAsInteger *LI = dyn_cast<nonloc::LocAsInteger>(&val))
+  if (nonloc::LocAsInteger *LI = dyn_cast<nonloc::LocAsInteger>(&val)) {
+    if (isLocType)
       return LI->getLoc();
+    
+    ASTContext &Ctx = ValMgr.getContext();    
+    
+    // FIXME: Support promotions/truncations.
+    if (Ctx.getTypeSize(castTy) == Ctx.getTypeSize(Ctx.VoidPtrTy))
+      return val;
+    
+    return UnknownVal();
+  }
+
+  if (const SymExpr *se = val.getAsSymbolicExpression()) {
+    ASTContext &Ctx = ValMgr.getContext();
+    QualType T = Ctx.getCanonicalType(se->getType(Ctx));
+    if (T == Ctx.getCanonicalType(castTy))
+      return val;
+    
+    return UnknownVal();
+  }
   
   if (!isa<nonloc::ConcreteInt>(val))
     return UnknownVal();