Index: include/clang/Analysis/PathSensitive/MemRegion.h
===================================================================
--- include/clang/Analysis/PathSensitive/MemRegion.h	(revision 59293)
+++ include/clang/Analysis/PathSensitive/MemRegion.h	(working copy)
@@ -42,12 +42,13 @@
               BEG_TYPED_REGIONS,
                CompoundLiteralRegionKind,
                StringRegionKind, ElementRegionKind,
+               AnonTypedRegionKind,
+               AnonPointeeRegionKind,
                // Decl Regions.
                  BEG_DECL_REGIONS,
                   VarRegionKind, FieldRegionKind,
                   ObjCIvarRegionKind, ObjCObjectRegionKind,
                  END_DECL_REGIONS,
-               AnonPointeeRegionKind,
               END_TYPED_REGIONS };  
 private:
   const Kind kind;
@@ -201,6 +202,32 @@
   }
 };
 
+class AnonTypedRegion : public TypedRegion {
+  friend class MemRegionManager;
+
+  QualType T;
+
+  AnonTypedRegion(QualType t, const MemRegion* sreg)
+    : TypedRegion(sreg, AnonTypedRegionKind), T(t) {}
+
+  static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T, 
+                            const MemRegion* superRegion);
+
+public:
+
+  QualType getType(ASTContext& C) const {
+    return T;
+  }
+
+  void Profile(llvm::FoldingSetNodeID& ID) const {
+    ProfileRegion(ID, T, superRegion);
+  }
+
+  static bool classof(const MemRegion* R) {
+    return R->getKind() == AnonTypedRegionKind;
+  }
+};
+
 /// AnonPointeeRegion - anonymous regions pointed-to by pointer function
 ///  parameters or pointer globals. In RegionStoreManager, we assume pointer
 ///  parameters or globals point at some anonymous region. Such regions are not
@@ -559,6 +586,8 @@
   ObjCIvarRegion* getObjCIvarRegion(const ObjCIvarDecl* ivd,
                                     const MemRegion* superRegion);
 
+  AnonTypedRegion* getAnonTypedRegion(QualType t, const MemRegion* superRegion);
+
   AnonPointeeRegion* getAnonPointeeRegion(const VarDecl* d);
 
   bool hasStackStorage(const MemRegion* R);
Index: lib/Analysis/MemRegion.cpp
===================================================================
--- lib/Analysis/MemRegion.cpp	(revision 59293)
+++ lib/Analysis/MemRegion.cpp	(working copy)
@@ -44,6 +44,13 @@
   ProfileRegion(ID, Ex, Cnt);
 }
 
+void AnonTypedRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T, 
+                                    const MemRegion* superRegion) {
+  ID.AddInteger((unsigned) AnonTypedRegionKind);
+  ID.Add(T);
+  ID.AddPointer(superRegion);
+}
+
 QualType AnonPointeeRegion::getType(ASTContext& C) const {
   QualType T = C.getCanonicalType(Pointer->getType());
   PointerType* PTy = cast<PointerType>(T.getTypePtr());
@@ -110,7 +117,7 @@
     ArrayType* AT = cast<ArrayType>(T.getTypePtr());
     return AT->getElementType();
   }
-  else if (isa<AllocaRegion>(superRegion)) {
+  else if (isa<AnonTypedRegion>(superRegion)) {
     PointerType* PtrT = cast<PointerType>(T.getTypePtr());
     QualType PTy = PtrT->getPointeeType();
     return C.getCanonicalType(PTy);
@@ -369,7 +376,24 @@
   return R;
 }
 
+AnonTypedRegion* 
+MemRegionManager::getAnonTypedRegion(QualType t, const MemRegion* superRegion) {
+  llvm::FoldingSetNodeID ID;
+  AnonTypedRegion::ProfileRegion(ID, t, superRegion);
 
+  void* InsertPos;
+  MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
+  AnonTypedRegion* R = cast_or_null<AnonTypedRegion>(data);
+
+  if (!R) {
+    R = (AnonTypedRegion*) A.Allocate<AnonTypedRegion>();
+    new (R) AnonTypedRegion(t, superRegion);
+    Regions.InsertNode(R, InsertPos);
+  }
+
+  return R;
+}
+
 AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
   llvm::FoldingSetNodeID ID;
   MemRegion* superRegion = getUnknownRegion();
Index: lib/Analysis/GRExprEngine.cpp
===================================================================
--- lib/Analysis/GRExprEngine.cpp	(revision 59294)
+++ lib/Analysis/GRExprEngine.cpp	(working copy)
@@ -1681,6 +1681,27 @@
       continue;
     }
 
+    // Check for casts from AllocaRegion pointer to typed pointer.
+    if (isa<loc::MemRegionVal>(V)) {
+      if (const AllocaRegion* AR =
+          dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(V).getRegion())) {
+
+        MemRegionManager& RM = getStateManager().getRegionManager();
+
+        // Create a new region to attach type information to it.
+        const AnonTypedRegion* TR = RM.getAnonTypedRegion(T, AR);
+
+        // Get the pointer to the first element.
+        // FIXME: get the pointer width from the target information.
+        llvm::APSInt Zero(llvm::APInt::getNullValue(32), false);
+        SVal ZeroIdx(nonloc::ConcreteInt(getBasicVals().getValue(Zero)));
+        const ElementRegion* ER = RM.getElementRegion(ZeroIdx, TR);
+
+        MakeNode(Dst, CastE, N, BindExpr(St, CastE, loc::MemRegionVal(ER)));
+        continue;
+      }
+    }
+
     // All other cases.
     MakeNode(Dst, CastE, N, BindExpr(St, CastE, EvalCast(V, CastE->getType())));
   }
