aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGRecordLayoutBuilder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r--lib/CodeGen/CGRecordLayoutBuilder.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp
index 7b7394a819..89b62bfa5a 100644
--- a/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -323,28 +323,19 @@ CGRecordLayoutBuilder::LayoutUnionField(const FieldDecl *Field,
if (FieldSize == 0)
return 0;
- const llvm::Type *FieldTy;
-
- if (!Field->getDeclName()) {
- // This is an unnamed bit-field, which shouldn't affect alignment on the
- // struct so we use an array of bytes for it.
-
- FieldTy = llvm::Type::getInt8Ty(Types.getLLVMContext());
+ const llvm::Type *FieldTy = llvm::Type::getInt8Ty(Types.getLLVMContext());
+ unsigned NumBytesToAppend =
+ llvm::RoundUpToAlignment(FieldSize, 8) / 8;
- unsigned NumBytesToAppend =
- llvm::RoundUpToAlignment(FieldSize, 8) / 8;
+ if (NumBytesToAppend > 1)
+ FieldTy = llvm::ArrayType::get(FieldTy, NumBytesToAppend);
- if (NumBytesToAppend > 1)
- FieldTy = llvm::ArrayType::get(FieldTy, NumBytesToAppend);
- } else
- FieldTy = Types.ConvertTypeForMemRecursive(Field->getType());
-
// Add the bit field info.
LLVMBitFields.push_back(
LLVMBitFieldInfo(Field, ComputeBitFieldInfo(Types, Field, 0, FieldSize)));
return FieldTy;
}
-
+
// This is a regular union field.
LLVMFields.push_back(LLVMFieldInfo(Field, 0));
return Types.ConvertTypeForMemRecursive(Field->getType());