summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-06-18 22:48:56 +0000
committerChris Lattner <sabre@nondot.org>2011-06-18 22:48:56 +0000
commitb2318662b6d2e6d9ea9917fd280dde0ba9a938ad (patch)
tree68fa7b164e186267795a98ba805b9ee2c7adcf40 /lib/VMCore
parentea049181a020b233cfd8a33583e2784d590e1dcb (diff)
downloadllvm-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')
-rw-r--r--lib/VMCore/Constants.cpp4
-rw-r--r--lib/VMCore/Type.cpp8
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 15d7793d58..0cf6c4ed82 100644
--- a/lib/VMCore/Constants.cpp
+++ b/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/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) {