diff options
| author | Chris Lattner <sabre@nondot.org> | 2011-08-12 17:31:02 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2011-08-12 17:31:02 +0000 |
| commit | 190552d3e0e11f8d0101e7cc26952a27bc2e4f99 (patch) | |
| tree | 28045d5b17e2d92de5d66692e7f9448b3bca81b0 /llvm/lib/VMCore | |
| parent | 45fc2a6a9b9e587b9a8fb4ad0e6444a315d47ab0 (diff) | |
| download | bcm5719-llvm-190552d3e0e11f8d0101e7cc26952a27bc2e4f99.tar.gz bcm5719-llvm-190552d3e0e11f8d0101e7cc26952a27bc2e4f99.zip | |
add new accessors to reflect new terminology in struct types.
llvm-svn: 137468
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/Type.cpp | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index bf8af07030a..f7ba59606ab 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/lib/VMCore/Type.cpp @@ -392,7 +392,7 @@ StructType *StructType::get(LLVMContext &Context, ArrayRef<Type*> ETypes, // Value not found. Create a new type! ST = new (Context.pImpl->TypeAllocator) StructType(Context); - ST->setSubclassData(SCDB_IsAnonymous); // Anonymous struct. + ST->setSubclassData(SCDB_IsLiteral); // Literal struct. ST->setBody(ETypes, isPacked); return ST; } @@ -478,6 +478,48 @@ StructType *StructType::get(Type *type, ...) { return llvm::StructType::get(Ctx, StructFields); } +StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements, + StringRef Name, bool isPacked) { + StructType *ST = createNamed(Context, Name); + ST->setBody(Elements, isPacked); + return ST; +} + +StructType *StructType::create(LLVMContext &Context, ArrayRef<Type*> Elements) { + return create(Context, Elements, StringRef()); +} + + +StructType *StructType::create(ArrayRef<Type*> Elements, StringRef Name, + bool isPacked) { + assert(!Elements.empty() && + "This method may not be invoked with an empty list"); + return create(Elements[0]->getContext(), Elements, Name, isPacked); +} + +StructType *StructType::create(ArrayRef<Type*> Elements) { + assert(!Elements.empty() && + "This method may not be invoked with an empty list"); + return create(Elements[0]->getContext(), Elements, StringRef()); +} + +StructType *StructType::create(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::create(Ctx, StructFields, Name); +} + + + + + StructType *StructType::createNamed(LLVMContext &Context, StringRef Name, ArrayRef<Type*> Elements, bool isPacked) { StructType *ST = createNamed(Context, Name); @@ -506,7 +548,7 @@ StructType *StructType::createNamed(StringRef Name, Type *type, ...) { } StringRef StructType::getName() const { - assert(!isAnonymous() && "Anonymous structs never have names"); + assert(!isLiteral() && "Literal structs never have names"); if (SymbolTableEntry == 0) return StringRef(); return ((StringMapEntry<StructType*> *)SymbolTableEntry)->getKey(); |

