diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-02-01 15:15:22 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-02-01 15:15:22 +0000 |
commit | 6f75550e40a9177db9979fc130ce3ece026b137d (patch) | |
tree | 783699bbd5b03f238cb398541349ef8ce8d2e687 /lib/AST/RecordLayoutBuilder.cpp | |
parent | fb7049a21969d856292c278950c0a5c70986d412 (diff) |
Basic support for -mms-bitfields, from Carl Norum!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r-- | lib/AST/RecordLayoutBuilder.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 7e15dcce37..730ec21358 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -1402,6 +1402,20 @@ void RecordLayoutBuilder::LayoutField(const FieldDecl *D) { std::pair<uint64_t, unsigned> FieldInfo = Context.getTypeInfo(D->getType()); FieldSize = FieldInfo.first; FieldAlign = FieldInfo.second; + + if (Context.getLangOptions().MSBitfields) { + // If MS bitfield layout is required, figure out what type is being + // laid out and align the field to the width of that type. + + // Resolve all typedefs down to their base type and round up the field + // alignment if necessary. + QualType T = Context.getBaseElementType(D->getType()); + if (const BuiltinType *BTy = T->getAs<BuiltinType>()) { + uint64_t TypeSize = Context.getTypeSize(BTy); + if (TypeSize > FieldAlign) + FieldAlign = TypeSize; + } + } } // The align if the field is not packed. This is to check if the attribute |