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 | b2318662b6d2e6d9ea9917fd280dde0ba9a938ad (patch) | |
tree | 68fa7b164e186267795a98ba805b9ee2c7adcf40 /lib/VMCore/Type.cpp | |
parent | ea049181a020b233cfd8a33583e2784d590e1dcb (diff) | |
download | llvm-b2318662b6d2e6d9ea9917fd280dde0ba9a938ad.tar.gz llvm-b2318662b6d2e6d9ea9917fd280dde0ba9a938ad.tar.bz2 llvm-b2318662b6d2e6d9ea9917fd280dde0ba9a938ad.tar.xz |
fix the varargs version of StructType::get to not require an LLVMContext, making usage
much cleaner.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133364 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r-- | lib/VMCore/Type.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index ebe431bdc2..9299070920 100644 --- a/lib/VMCore/Type.cpp +++ b/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) { |