Update to match mainline ConstantStruct::get API change.  Also, use 
ConvertType on InitListExprs as they are being converted.  This is
needed for a forthcoming patch, and improves the IR generated anyway
(see additional type names in testcases). 

This patch also converts a bunch of std::vector's in CGObjCMac to use
C arrays.  There are a ton more that should be converted as well.

llvm-svn: 133413
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 75e5661..5184f47 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -433,9 +433,19 @@
   if (!Builder.Build(ILE))
     return 0;
   
+  // Pick the type to use.  If the type is layout identical to the ConvertType
+  // type then use it, otherwise use whatever the builder produced for us.
+  const llvm::StructType *STy =
+      llvm::ConstantStruct::getTypeForElements(CGM.getLLVMContext(),
+                                               Builder.Elements,Builder.Packed);
+  const llvm::Type *ILETy = CGM.getTypes().ConvertType(ILE->getType());
+  if (const llvm::StructType *ILESTy = dyn_cast<llvm::StructType>(ILETy)) {
+    if (ILESTy->isLayoutIdentical(STy))
+      STy = ILESTy;
+  }
+    
   llvm::Constant *Result =
-  llvm::ConstantStruct::get(CGM.getLLVMContext(),
-                            Builder.Elements, Builder.Packed);
+    llvm::ConstantStruct::get(STy, Builder.Elements);
   
   assert(Builder.NextFieldOffsetInChars.RoundUpToAlignment(
            Builder.getAlignment(Result)) ==
@@ -988,7 +998,10 @@
                                           Result.Val.getComplexIntImag());
 
       // FIXME: the target may want to specify that this is packed.
-      return llvm::ConstantStruct::get(VMContext, Complex, 2, false);
+      llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
+                                                    Complex[1]->getType(),
+                                                    NULL);
+      return llvm::ConstantStruct::get(STy, Complex);
     }
     case APValue::Float:
       return llvm::ConstantFP::get(VMContext, Result.Val.getFloat());
@@ -1001,7 +1014,10 @@
                                          Result.Val.getComplexFloatImag());
 
       // FIXME: the target may want to specify that this is packed.
-      return llvm::ConstantStruct::get(VMContext, Complex, 2, false);
+      llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
+                                                    Complex[1]->getType(),
+                                                    NULL);
+      return llvm::ConstantStruct::get(STy, Complex);
     }
     case APValue::Vector: {
       llvm::SmallVector<llvm::Constant *, 4> Inits;