When transforming an InitListExpr, if we already computed a non-dependent type for the InitListExpr, keep it

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86559 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 33d2623..641ea24 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -188,13 +188,11 @@
       Var->setInvalidDecl();
     else if (!D->getType()->isDependentType() &&
              !D->getInit()->isTypeDependent() &&
-             !D->getInit()->isValueDependent() &&
-             !isa<InitListExpr>(D->getInit())) {
+             !D->getInit()->isValueDependent()) {
       // If neither the declaration's type nor its initializer are dependent,
       // we don't want to redo all the checking, especially since the
       // initializer might have been wrapped by a CXXConstructExpr since we did
       // it the first time.
-      // FIXME: The InitListExpr handling here is a hack!
       Var->setInit(SemaRef.Context, Init.takeAs<Expr>());
     }
     else if (ParenListExpr *PLE = dyn_cast<ParenListExpr>((Expr *)Init.get())) {
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 767725a..799d01b 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -1063,8 +1063,18 @@
   /// Subclasses may override this routine to provide different behavior.
   OwningExprResult RebuildInitList(SourceLocation LBraceLoc,
                                    MultiExprArg Inits,
-                                   SourceLocation RBraceLoc) {
-    return SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc);
+                                   SourceLocation RBraceLoc,
+                                   QualType ResultTy) {
+    OwningExprResult Result
+      = SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc);
+    if (Result.isInvalid() || ResultTy->isDependentType())
+      return move(Result);
+    
+    // Patch in the result type we were given, which may have been computed
+    // when the initial InitListExpr was built.
+    InitListExpr *ILE = cast<InitListExpr>((Expr *)Result.get());
+    ILE->setType(ResultTy);
+    return move(Result);
   }
 
   /// \brief Build a new designated initializer expression.
@@ -3893,7 +3903,7 @@
     return SemaRef.Owned(E->Retain());
 
   return getDerived().RebuildInitList(E->getLBraceLoc(), move_arg(Inits),
-                                      E->getRBraceLoc());
+                                      E->getRBraceLoc(), E->getType());
 }
 
 template<typename Derived>