diff options
author | Warren Hunt <whunt@google.com> | 2013-11-06 00:54:59 +0000 |
---|---|---|
committer | Warren Hunt <whunt@google.com> | 2013-11-06 00:54:59 +0000 |
commit | 6b7048ddd848f9d30eab74ea02b58f89f8681b6f (patch) | |
tree | a619b2b2c4844d355a0f967edee4fdb1452463e2 /clang/lib/AST/RecordLayoutBuilder.cpp | |
parent | c13f43f4f95edcd0138e3385944c6ca84ad70617 (diff) | |
download | bcm5719-llvm-6b7048ddd848f9d30eab74ea02b58f89f8681b6f.tar.gz bcm5719-llvm-6b7048ddd848f9d30eab74ea02b58f89f8681b6f.zip |
Microsoft adds weird padding before virtual bases if the last field was a bitfield
This patch adds the same behavior to clang.
Differential Revision: http://llvm-reviews.chandlerc.com/D2103
llvm-svn: 194115
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 87d00bc9f5d..08c9da35873 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -2014,6 +2014,10 @@ static bool isMsLayout(const RecordDecl* D) { // one. // * The last zero size virtual base may be placed at the end of the struct. // and can potentially alias a zero sized type in the next struct. +// * If the last field is a non-zero length bitfield and we have any virtual +// bases then some extra padding is added before the virtual bases for no +// obvious reason. + namespace { struct MicrosoftRecordLayoutBuilder { @@ -2499,6 +2503,11 @@ void MicrosoftRecordLayoutBuilder::layoutVirtualBases(const CXXRecordDecl *RD) { llvm::SmallPtrSet<const CXXRecordDecl *, 2> HasVtordisp = computeVtorDispSet(RD); + // If the last field we laid out was a non-zero length bitfield then add some + // extra padding for no obvious reason. + if (LastFieldIsNonZeroWidthBitfield) + Size += CurrentBitfieldSize; + // Iterate through the virtual bases and lay them out. for (CXXRecordDecl::base_class_const_iterator i = RD->vbases_begin(), e = RD->vbases_end(); |