Further cleanup of region invalidation code. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74816 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index c836de9..deb546a 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -111,17 +111,28 @@
 }
 
 const GRState *StoreManager::InvalidateRegion(const GRState *state,
-                                              const TypedRegion *R,
+                                              const MemRegion *R,
                                               const Expr *E, unsigned Count) {
+  ASTContext& Ctx = StateMgr.getContext();
+
   if (!R->isBoundable())
     return state;
 
-  ASTContext& Ctx = StateMgr.getContext();
-  QualType T = R->getValueType(Ctx);
+  if (isa<AllocaRegion>(R) || isa<SymbolicRegion>(R)) {
+    // Invalidate the alloca region by setting its default value to 
+    // conjured symbol. The type of the symbol is irrelavant.
+    SVal V = ValMgr.getConjuredSymbolVal(E, Ctx.IntTy, Count);
+    state = setDefaultValue(state, R, V);
+    return state;
+  }
+
+  const TypedRegion *TR = cast<TypedRegion>(R);
+
+  QualType T = TR->getValueType(Ctx);
 
   if (Loc::IsLocType(T) || (T->isIntegerType() && T->isScalarType())) {
     SVal V = ValMgr.getConjuredSymbolVal(E, T, Count);
-    return Bind(state, ValMgr.makeLoc(R), V);
+    return Bind(state, ValMgr.makeLoc(TR), V);
   }
   else if (const RecordType *RT = T->getAsStructureType()) {
     // FIXME: handle structs with default region value.
@@ -138,7 +149,7 @@
       // For now just handle scalar fields.
       FieldDecl *FD = *FI;
       QualType FT = FD->getType();
-      const FieldRegion* FR = MRMgr.getFieldRegion(FD, R);
+      const FieldRegion* FR = MRMgr.getFieldRegion(FD, TR);
       
       if (Loc::IsLocType(FT) || 
           (FT->isIntegerType() && FT->isScalarType())) {
@@ -158,10 +169,10 @@
     // Set the default value of the array to conjured symbol.
     SVal V = ValMgr.getConjuredSymbolVal(E, AT->getElementType(),
                                          Count);
-    state = setDefaultValue(state, R, V);
+    state = setDefaultValue(state, TR, V);
   } else {
     // Just blast away other values.
-    state = Bind(state, ValMgr.makeLoc(R), UnknownVal());
+    state = Bind(state, ValMgr.makeLoc(TR), UnknownVal());
   }
   
   return state;