Index: include/clang/Analysis/PathSensitive/Store.h
===================================================================
--- include/clang/Analysis/PathSensitive/Store.h	(revision 58306)
+++ include/clang/Analysis/PathSensitive/Store.h	(working copy)
@@ -55,13 +55,25 @@
   virtual Store BindCompoundLiteral(Store store, const CompoundLiteralRegion* R,
                                     const SVal* BegInit,
                                     const SVal* EndInit) = 0;
-  
+
+  /// Do things kind of like 'AddDecl()': Create region for compound literal,
+  /// bind the init value to the region, create sub regions when
+  /// necessary. Assume all init list exprs are evaluated and has Expr->SVal
+  /// bindings in the Environment. This interface is intended to replace the
+  /// above BindCompoundLiteral. The AddDecl() will be changed to follow the
+  /// style of this interface.
+  virtual Store AddCompoundLiteral(Store store, CompoundLiteralExpr* CLE,
+                                   const GRState* state) = 0;
+
   virtual Store getInitialStore() = 0;
   virtual MemRegionManager& getRegionManager() = 0;
 
   virtual SVal getLValueVar(const GRState* St, const VarDecl* VD) = 0;
 
   virtual SVal getLValueString(const GRState* St, const StringLiteral* S) = 0;
+
+  virtual SVal getLValueCompoundLiteral(const GRState* St, 
+                                        const CompoundLiteralExpr* CL) = 0;
   
   virtual SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D,
                              SVal Base) = 0;
Index: include/clang/Analysis/PathSensitive/GRState.h
===================================================================
--- include/clang/Analysis/PathSensitive/GRState.h	(revision 58306)
+++ include/clang/Analysis/PathSensitive/GRState.h	(working copy)
@@ -338,6 +338,9 @@
                                      const CompoundLiteralRegion* R,
                                      const SVal* BegInit, const SVal* EndInit);
 
+  const GRState* AddCompoundLiteral(const GRState* state,
+                                    CompoundLiteralExpr* CL);
+
   const GRState* RemoveDeadBindings(const GRState* St, Stmt* Loc, 
                                        const LiveVariables& Liveness,
                                        DeadSymbolsTy& DeadSyms);
@@ -368,7 +371,12 @@
   SVal GetLValue(const GRState* St, const StringLiteral* E) {
     return StoreMgr->getLValueString(St, E);
   }
-  
+
+  // Get the lvalue for a CompoundLiteral.
+  SVal GetLValue(const GRState* St, const CompoundLiteralExpr* CL) {
+    return StoreMgr->getLValueCompoundLiteral(St, CL);
+  }
+
   // Get the lvalue for an ivar reference.
   SVal GetLValue(const GRState* St, const ObjCIvarDecl* D, SVal Base) {
     return StoreMgr->getLValueIvar(St, D, Base);
Index: include/clang/Analysis/PathSensitive/MemRegion.h
===================================================================
--- include/clang/Analysis/PathSensitive/MemRegion.h	(revision 58313)
+++ include/clang/Analysis/PathSensitive/MemRegion.h	(working copy)
@@ -420,7 +420,7 @@
   MemSpaceRegion* getUnknownRegion();
 
   bool isGlobalsRegion(const MemRegion* R) { 
-    assert(R && globals);
+    assert(R);
     return R == globals; 
   }
   
Index: lib/Analysis/GRState.cpp
===================================================================
--- lib/Analysis/GRState.cpp	(revision 58306)
+++ lib/Analysis/GRState.cpp	(working copy)
@@ -112,6 +112,19 @@
   return getPersistentState(newState);
 }
 
+const GRState*
+GRStateManager::AddCompoundLiteral(const GRState* state,
+                                   CompoundLiteralExpr* CL) {
+  Store oldStore = state->getStore();
+  Store newStore = StoreMgr->AddCompoundLiteral(oldStore, CL, state);
+  if (newStore == oldStore)
+    return state;
+
+  GRState newState = *state;
+  newState.St = newStore;
+  return getPersistentState(newState);
+}
+
 const GRState* GRStateManager::Unbind(const GRState* St, Loc LV) {
   Store OldStore = St->getStore();
   Store NewStore = StoreMgr->Remove(OldStore, LV);
Index: lib/Analysis/BasicStore.cpp
===================================================================
--- lib/Analysis/BasicStore.cpp	(revision 58306)
+++ lib/Analysis/BasicStore.cpp	(working copy)
@@ -50,9 +50,15 @@
                             const SVal* BegInit, const SVal* EndInit) {
     return store;
   }
-  
+
+  Store AddCompoundLiteral(Store store, CompoundLiteralExpr*, const GRState*) {
+    return store;
+  }
+
   SVal getLValueVar(const GRState* St, const VarDecl* VD);
   SVal getLValueString(const GRState* St, const StringLiteral* S);
+  SVal getLValueCompoundLiteral(const GRState* St, 
+                                const CompoundLiteralExpr* CL);
   SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
   SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D);  
   SVal getLValueElement(const GRState* St, SVal Base, SVal Offset);
@@ -99,7 +105,12 @@
                                         const StringLiteral* S) {
   return loc::MemRegionVal(MRMgr.getStringRegion(S));
 }
-  
+
+SVal BasicStoreManager::getLValueCompoundLiteral(const GRState* St,
+                                                 const CompoundLiteralExpr* CL){
+  return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL));
+}
+
 SVal BasicStoreManager::getLValueIvar(const GRState* St, const ObjCIvarDecl* D,
                                       SVal Base) {
   return UnknownVal();
Index: lib/Analysis/RegionStore.cpp
===================================================================
--- lib/Analysis/RegionStore.cpp	(revision 58306)
+++ lib/Analysis/RegionStore.cpp	(working copy)
@@ -55,8 +55,14 @@
     return store;
   }
 
+  Store AddCompoundLiteral(Store store, CompoundLiteralExpr* CLE,
+                           const GRState* state);
+
   SVal getLValueString(const GRState* St, const StringLiteral* S);
 
+  SVal getLValueCompoundLiteral(const GRState* St,
+                                const CompoundLiteralExpr* CL);
+
   SVal getLValueVar(const GRState* St, const VarDecl* VD);
   
   SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
@@ -113,6 +119,18 @@
 
   Store InitializeArrayToUndefined(Store store, QualType T, MemRegion* BaseR);
   Store InitializeStructToUndefined(Store store, QualType T, MemRegion* BaseR);
+
+  Store InitializeArrayWithInitList(Store store,
+                                    QualType T,
+                                    MemRegion* BaseR,
+                                    InitListExpr* ILE,
+                                    const GRState* state);
+
+  Store InitializeStructWithInitList(Store store,
+                                     QualType T,
+                                     MemRegion* BaseR,
+                                     InitListExpr* ILE,
+                                     const GRState* state);
 };
 
 } // end anonymous namespace
@@ -121,11 +139,56 @@
   return new RegionStoreManager(StMgr);
 }
 
+Store RegionStoreManager::AddCompoundLiteral(Store store, 
+                                             CompoundLiteralExpr* CLE,
+                                             const GRState* state) {
+
+  // A CompoundLiteral is an unnamed object, so we create a MemRegion for it.
+  CompoundLiteralRegion* CLR = MRMgr.getCompoundLiteralRegion(CLE);
+
+  // Initialize the CompoundLiteral object according to its type.
+  QualType T = CLE->getType();
+
+  InitListExpr* ILE = cast<InitListExpr>(CLE->getInitializer());
+
+  if (Loc::IsLocType(T) || T->isIntegerType()) {
+    // Scalar type, simply fetch the sval of the init expr, bind the region to
+    // it.
+    assert(++(ILE->child_begin()) == ILE->child_end());
+
+    Stmt::child_iterator CI = ILE->child_begin();
+
+    SVal V = StateMgr.GetSVal(state, cast<Expr>(*CI));
+
+    store = Bind(store, loc::MemRegionVal(CLR), V);
+
+    return store;
+  }
+
+  if (T->isArrayType()) {
+    store = InitializeArrayWithInitList(store, T, CLR, ILE, state);
+    return store;
+  }
+
+  if (T->isStructureType()) {
+    store = InitializeStructWithInitList(store, T, CLR, ILE, state);
+    return store;
+  }
+
+  assert(0 && "unprocessed CompoundLiteral type");
+  return store;
+}
+
 SVal RegionStoreManager::getLValueString(const GRState* St, 
                                          const StringLiteral* S) {
   return loc::MemRegionVal(MRMgr.getStringRegion(S));
 }
 
+SVal RegionStoreManager::getLValueCompoundLiteral(const GRState* St,
+                                                 const CompoundLiteralExpr* CL){
+  return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL));
+}
+
 SVal RegionStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) {
   return loc::MemRegionVal(MRMgr.getVarRegion(VD));
 }
@@ -386,6 +449,51 @@
   return store;
 }
 
+Store RegionStoreManager::InitializeArrayWithInitList(Store store, 
+                                                      QualType T,
+                                                      MemRegion* BaseR,
+                                                      InitListExpr* ILE,
+                                                      const GRState* state) {
+  assert(T->isArrayType());
+  assert(BaseR);
+  assert(ILE);
+
+  bool isGlobal=MRMgr.isGlobalsRegion(cast<SubRegion>(BaseR)->getSuperRegion());
+
+  BasicValueFactory& BasicVals = StateMgr.getBasicVals();
+
+  if (ConstantArrayType* CAT = dyn_cast<ConstantArrayType>(T.getTypePtr())) {
+    llvm::APInt Size = CAT->getSize();
+    llvm::APInt i = llvm::APInt::getNullValue(Size.getBitWidth());
+
+    InitListExpr::child_iterator I = ILE->child_begin(), E = ILE->child_end();
+
+    for (; i != Size; ++i) {
+      // Get the unique SVal.
+      nonloc::ConcreteInt Idx(BasicVals.getValue(llvm::APSInt(i)));
+      ElementRegion* ER = MRMgr.getElementRegion(Idx, BaseR);
+
+      if (I != E) {
+        SVal V = StateMgr.GetSVal(state, cast<Expr>(*I));
+        store = Bind(store, loc::MemRegionVal(ER), V);
+        ++I;
+
+      } else {
+        if (isGlobal) {
+          llvm::APInt ZeroInt = llvm::APInt::getNullValue(Size.getBitWidth());
+          // Get the unique SVal.
+          nonloc::ConcreteInt ZeroVal(BasicVals.getValue(llvm::APSInt(ZeroInt)));
+          store = Bind(store, loc::MemRegionVal(ER), ZeroVal);
+        } else
+          store = Bind(store, loc::MemRegionVal(ER), UndefinedVal());
+      }
+
+    }
+  }
+
+  return store;
+}
+
 Store RegionStoreManager::InitializeStructToUndefined(Store store, QualType T,
                                                       MemRegion* BaseR) {
   QualType CT = StateMgr.getContext().getCanonicalType(T);
@@ -412,3 +520,38 @@
 
   return store;
 }
+
+Store RegionStoreManager::InitializeStructWithInitList(Store store,
+                                                       QualType T,
+                                                       MemRegion* BaseR,
+                                                       InitListExpr* ILE,
+                                                       const GRState* state) {
+  QualType CT = StateMgr.getContext().getCanonicalType(T);
+  const RecordType* RT = cast<RecordType>(CT.getTypePtr());
+  RecordDecl* RD = RT->getDecl();
+  assert(RD->isDefinition());
+
+  RecordDecl::field_iterator FI = RD->field_begin(), FE = RD->field_end();
+  InitListExpr::child_iterator EI = ILE->child_begin(), EE = ILE->child_end();
+
+  for (; FI != FE; ++FI, ++EI) {
+
+    QualType FTy = (*FI)->getType();
+    FieldRegion* FR = MRMgr.getFieldRegion(*FI, BaseR);
+
+    if (Loc::IsLocType(FTy) || FTy->isIntegerType()) {
+      SVal V = StateMgr.GetSVal(state, cast<Expr>(*EI));
+      store = Bind(store, loc::MemRegionVal(FR), V);
+
+    } else if (FTy->isArrayType()) {
+      store = InitializeArrayWithInitList(store, FTy, FR, 
+                                          cast<InitListExpr>(*EI), state);
+
+    } else if (FTy->isStructureType()) {
+      store = InitializeStructWithInitList(store, FTy, FR, 
+                                           cast<InitListExpr>(*EI), state);
+    }
+  }
+
+  return store;
+}
Index: lib/Analysis/GRExprEngine.cpp
===================================================================
--- lib/Analysis/GRExprEngine.cpp	(revision 58306)
+++ lib/Analysis/GRExprEngine.cpp	(working copy)
@@ -1564,23 +1564,13 @@
   Visit(ILE, Pred, Tmp);
   
   for (NodeSet::iterator I = Tmp.begin(), EI = Tmp.end(); I!=EI; ++I) {
-    // Retrieve the initializer values from the environment and store them
-    // into a vector that will then be handed off to the Store.    
+
     const GRState* St = GetState(*I);    
-    llvm::SmallVector<SVal, 10> IVals;
-    IVals.reserve(ILE->getNumInits());
-    
-    for (Stmt::child_iterator J=ILE->child_begin(), EJ=ILE->child_end();
-          J!=EJ; ++J)
-      IVals.push_back(GetSVal(St, cast<Expr>(*J)));
 
-    const CompoundLiteralRegion* R = 
-      StateMgr.getRegionManager().getCompoundLiteralRegion(CL);
-    
-    assert (!IVals.empty() && "Initializer cannot be empty.");
+    St = StateMgr.AddCompoundLiteral(St, CL);
 
-    St = StateMgr.BindCompoundLiteral(St, R, &IVals[0], &IVals[0]+IVals.size());
-    MakeNode(Dst, CL, *I, SetSVal(St, CL, loc::MemRegionVal(R)));
+    // FIXME: CompoundLiteralExpr can be used in both lvalue and rvalue context.
+    MakeNode(Dst, CL, *I, SetSVal(St, CL, StateMgr.GetLValue(St, CL)));
   }
 }
 
