diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-04-22 08:50:59 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-04-22 08:50:59 +0000 |
commit | ae287239879386b9abf6da50a67bbb7fe81897f1 (patch) | |
tree | 1df54ae8c3f290a8105bc2fd74e5970b5a403d8c /lib/CodeGen/CodeGenTypes.cpp | |
parent | 3fea0c01e178e46eb20e81de4907a3d144c21fd6 (diff) |
Simplify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 24f4885970..f8d6436cc4 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -464,11 +464,20 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) { const llvm::Type *ResultType; const RecordDecl *RD = cast<const RecordDecl>(TD); - if (TD->isStruct() || TD->isClass()) { + + // There isn't any extra information for empty structures/unions. + if (RD->field_empty(getContext())) { + ResultType = llvm::StructType::get(std::vector<const llvm::Type*>()); + } else { // Layout fields. RecordOrganizer RO(*this, *RD); - RO.layoutStructFields(Context.getASTRecordLayout(RD)); + if (TD->isStruct() || TD->isClass()) + RO.layoutStructFields(Context.getASTRecordLayout(RD)); + else { + assert(TD->isUnion() && "unknown tag decl kind!"); + RO.layoutUnionFields(Context.getASTRecordLayout(RD)); + } // Get llvm::StructType. const Type *Key = @@ -476,27 +485,6 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) { CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(), RO.getPaddingFields()); ResultType = RO.getLLVMType(); - - } else if (TD->isUnion()) { - // Just use the largest element of the union, breaking ties with the - // highest aligned member. - if (!RD->field_empty(getContext())) { - RecordOrganizer RO(*this, *RD); - - RO.layoutUnionFields(Context.getASTRecordLayout(RD)); - - // Get llvm::StructType. - const Type *Key = - Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr(); - CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(), - RO.getPaddingFields()); - ResultType = RO.getLLVMType(); - } else { - ResultType = llvm::StructType::get(std::vector<const llvm::Type*>()); - } - } else { - assert(0 && "FIXME: Unknown tag decl kind!"); - abort(); } // Refine our Opaque type to ResultType. This can invalidate ResultType, so |