diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-06-20 04:01:35 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-06-20 04:01:35 +0000 |
| commit | e64d7ba153cae6c196ece68bad4536494e97ccb6 (patch) | |
| tree | ea88bec822eba15c1e58b69cf16164876a3748d8 /clang/lib/CodeGen/CGExprConstant.cpp | |
| parent | cc19efaa97b3e1c2988042d716577831e813fdb9 (diff) | |
| download | bcm5719-llvm-e64d7ba153cae6c196ece68bad4536494e97ccb6.tar.gz bcm5719-llvm-e64d7ba153cae6c196ece68bad4536494e97ccb6.zip | |
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
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprConstant.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 75e566110cd..5184f475375 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -433,9 +433,19 @@ llvm::Constant *ConstStructBuilder:: 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 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, 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 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, 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; |

