[llvm-branch-commits] [llvm-branch] r134002 - in /llvm/branches/type-system-rewrite: include/llvm/DerivedTypes.h lib/VMCore/Type.cpp
Jay Foad
jay.foad at gmail.com
Tue Jun 28 03:31:31 PDT 2011
Author: foad
Date: Tue Jun 28 05:31:31 2011
New Revision: 134002
URL: http://llvm.org/viewvc/llvm-project?rev=134002&view=rev
Log:
Add varargs forms of StructType::createNamed() and
StructType::setBody().
Modified:
llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h
llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp
Modified: llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h?rev=134002&r1=134001&r2=134002&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h (original)
+++ llvm/branches/type-system-rewrite/include/llvm/DerivedTypes.h Tue Jun 28 05:31:31 2011
@@ -213,6 +213,7 @@
static StructType *createNamed(LLVMContext &Context, StringRef Name,
ArrayRef<Type*> Elements,
bool isPacked = false);
+ static StructType *createNamed(StringRef Name, Type *elt1, ...) END_WITH_NULL;
/// StructType::get - This static method is the primary way to create a
/// StructType.
@@ -259,6 +260,7 @@
/// setBody - Specify a body for an opaque type.
void setBody(ArrayRef<Type*> Elements, bool isPacked = false);
+ void setBody(Type *elt1, ...) END_WITH_NULL;
/// isValidElementType - Return true if the specified type is valid as a
/// element type.
Modified: llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp?rev=134002&r1=134001&r2=134002&view=diff
==============================================================================
--- llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp (original)
+++ llvm/branches/type-system-rewrite/lib/VMCore/Type.cpp Tue Jun 28 05:31:31 2011
@@ -493,6 +493,19 @@
return createNamed(Elements[0]->getContext(), Name, Elements, isPacked);
}
+StructType *StructType::createNamed(StringRef Name, Type *type, ...) {
+ assert(type != 0 && "Cannot create a struct type with no elements with this");
+ LLVMContext &Ctx = type->getContext();
+ va_list ap;
+ SmallVector<llvm::Type*, 8> StructFields;
+ va_start(ap, type);
+ while (type) {
+ StructFields.push_back(type);
+ type = va_arg(ap, llvm::Type*);
+ }
+ return llvm::StructType::createNamed(Ctx, Name, StructFields);
+}
+
StringRef StructType::getName() const {
assert(!isAnonymous() && "Anonymous structs never have names");
if (SymbolTableEntry == 0) return StringRef();
@@ -500,6 +513,18 @@
return ((StringMapEntry<StructType*> *)SymbolTableEntry)->getKey();
}
+void StructType::setBody(Type *type, ...) {
+ assert(type != 0 && "Cannot create a struct type with no elements with this");
+ va_list ap;
+ SmallVector<llvm::Type*, 8> StructFields;
+ va_start(ap, type);
+ while (type) {
+ StructFields.push_back(type);
+ type = va_arg(ap, llvm::Type*);
+ }
+ setBody(StructFields);
+}
+
bool StructType::isValidElementType(const Type *ElemTy) {
return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
!ElemTy->isMetadataTy() && !ElemTy->isFunctionTy();
More information about the llvm-branch-commits
mailing list