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 | dbe39270269daa6dc9cba699c1de9de309a7d4fb (patch) | |
| tree | 4a56c1c3708e7c0371dc31b7dbccb1ae0c461ad1 /clang/lib/AST/RecordLayoutBuilder.cpp | |
| parent | de7a357a3044958be73c3f7fa41cb1574a680771 (diff) | |
| download | bcm5719-llvm-dbe39270269daa6dc9cba699c1de9de309a7d4fb.tar.gz bcm5719-llvm-dbe39270269daa6dc9cba699c1de9de309a7d4fb.zip | |
Basic support for -mms-bitfields, from Carl Norum!
llvm-svn: 124661
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
| -rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 7e15dcce37c..730ec213580 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/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 |

