diff options
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index ec791564893..b692025aa0f 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -2014,9 +2014,9 @@ 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. +// * If the last field is a non-zero length bitfield, all virtual bases will +// have extra padding added before them for no obvious reason. The padding +// has the same number of bits as the type of the bitfield. // * When laying out empty non-virtual bases, an extra byte of padding is added // if the non-virtual base before the empty non-virtual base has a vbptr. // * The ABI attempts to avoid aliasing of zero sized bases by adding padding @@ -2558,17 +2558,16 @@ 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(); i != e; ++i) { const CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(i->getType()->castAs<RecordType>()->getDecl()); + // 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; layoutVirtualBase(BaseDecl, HasVtordisp.count(BaseDecl)); } } |