diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-06-18 22:48:56 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-06-18 22:48:56 +0000 |
| commit | f3f545ea8a6e444b23bbf7d70de0c7f8ef1a1807 (patch) | |
| tree | dbab6d67b71391e041af6e3aa7df5631a3d370cd /llvm/lib/VMCore | |
| parent | b97d926bce0fcdbafccd02abbdfac0f21ef788cf (diff) | |
| download | bcm5719-llvm-f3f545ea8a6e444b23bbf7d70de0c7f8ef1a1807.tar.gz bcm5719-llvm-f3f545ea8a6e444b23bbf7d70de0c7f8ef1a1807.zip | |
fix the varargs version of StructType::get to not require an LLVMContext, making usage
much cleaner.
llvm-svn: 133364
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/VMCore/Type.cpp | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 15d7793d589..0cf6c4ed82d 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -1537,8 +1537,8 @@ Constant *ConstantExpr::getSizeOf(const Type* Ty) { Constant *ConstantExpr::getAlignOf(const Type* Ty) { // alignof is implemented as: (i64) gep ({i1,Ty}*)null, 0, 1 // Note that a non-inbounds gep is used, as null isn't within any object. - const Type *AligningTy = StructType::get(Ty->getContext(), - Type::getInt1Ty(Ty->getContext()), Ty, NULL); + const Type *AligningTy = + StructType::get(Type::getInt1Ty(Ty->getContext()), Ty, NULL); Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo()); Constant *Zero = ConstantInt::get(Type::getInt64Ty(Ty->getContext()), 0); Constant *One = ConstantInt::get(Type::getInt32Ty(Ty->getContext()), 1); diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index ebe431bdc2f..92990709202 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/lib/VMCore/Type.cpp @@ -939,15 +939,17 @@ StructType *StructType::get(LLVMContext &Context, return ST; } -StructType *StructType::get(LLVMContext &Context, const Type *type, ...) { +StructType *StructType::get(const Type *type, ...) { + assert(type != 0 && "Cannot create a struct type with no elements with this"); + LLVMContext &Ctx = type->getContext(); va_list ap; - std::vector<const llvm::Type*> StructFields; + SmallVector<const llvm::Type*, 8> StructFields; va_start(ap, type); while (type) { StructFields.push_back(type); type = va_arg(ap, llvm::Type*); } - return llvm::StructType::get(Context, StructFields); + return llvm::StructType::get(Ctx, StructFields); } bool StructType::isValidElementType(const Type *ElemTy) { |

