Preserve type source information in compound literal expressions.
Patch by Enea Zaffanella!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93752 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index c49f5e8..21c9cbf 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -533,6 +533,7 @@
 unsigned PCHStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
   VisitExpr(E);
   E->setLParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+  E->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
   E->setInitializer(cast<Expr>(StmtStack.back()));
   E->setFileScope(Record[Idx++]);
   return 1;
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index a5ad859..fdfdfef 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -496,6 +496,7 @@
 void PCHStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
   VisitExpr(E);
   Writer.AddSourceLocation(E->getLParenLoc(), Record);
+  Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
   Writer.WriteSubStmt(E->getInitializer());
   Record.push_back(E->isFileScope());
   Code = pch::EXPR_COMPOUND_LITERAL;
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 68c23c7..5a5b0ea 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -2514,8 +2514,10 @@
         InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
                                              &InitExprs[0], InitExprs.size(),
                                              SourceLocation());
-        SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superType, ILE,
-                                           false);
+        TypeSourceInfo *superTInfo
+          = Context->getTrivialTypeSourceInfo(superType);
+        SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(),
+                                                     superTInfo, ILE, false);
         // struct objc_super *
         SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf,
                                  Context->getPointerType(SuperRep->getType()),
@@ -2597,7 +2599,10 @@
         InitListExpr *ILE = new (Context) InitListExpr(SourceLocation(),
                                              &InitExprs[0], InitExprs.size(),
                                              SourceLocation());
-        SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superType, ILE, false);
+        TypeSourceInfo *superTInfo
+          = Context->getTrivialTypeSourceInfo(superType);
+        SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(),
+                                                     superTInfo, ILE, false);
       }
       MsgExprs.push_back(SuperRep);
     } else {