aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-07-27 17:10:54 +0000
committerAnders Carlsson <andersca@mac.com>2009-07-27 17:10:54 +0000
commit696798febaf1f69020cdf7474b91e71736c5aa69 (patch)
tree434dffae64ee55b07a724ad6ee70585dae79ce24 /lib/CodeGen
parentabdad358b53d0efd1d89ea434b7078600a656d1f (diff)
Use the CGRecordLayoutBuilder even if there are no fields, because in C++ an empty class will have a padding byte.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77205 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp45
1 files changed, 18 insertions, 27 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index 21c7c38eee..e55ca2ad9c 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -453,36 +453,27 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) {
const llvm::Type *ResultType;
const RecordDecl *RD = cast<const RecordDecl>(TD);
- // There isn't any extra information for empty structures/unions.
- if (RD->field_empty()) {
- ResultType = llvm::StructType::get(std::vector<const llvm::Type*>());
- } else {
- // Layout fields.
- CGRecordLayout *Layout =
- CGRecordLayoutBuilder::ComputeLayout(*this, RD);
+ // Layout fields.
+ CGRecordLayout *Layout =
+ CGRecordLayoutBuilder::ComputeLayout(*this, RD);
- if (!Layout) {
- // Layout fields.
- RecordOrganizer RO(*this, *RD);
-
- if (TD->isStruct() || TD->isClass())
- RO.layoutStructFields(Context.getASTRecordLayout(RD));
- else {
- assert(TD->isUnion() && "unknown tag decl kind!");
- RO.layoutUnionFields(Context.getASTRecordLayout(RD));
- }
-
- Layout = new CGRecordLayout(RO.getLLVMType(),
- RO.getPaddingFields());
+ if (!Layout) {
+ // Layout fields.
+ RecordOrganizer RO(*this, *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 =
- Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr();
-
- CGRecordLayouts[Key] = Layout;
- ResultType = Layout->getLLVMType();
+
+ Layout = new CGRecordLayout(RO.getLLVMType(),
+ RO.getPaddingFields());
}
+
+ CGRecordLayouts[Key] = Layout;
+ ResultType = Layout->getLLVMType();
// Refine our Opaque type to ResultType. This can invalidate ResultType, so
// make sure to read the result out of the holder.