summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
diff options
context:
space:
mode:
authorWarren Hunt <whunt@google.com>2013-12-06 20:16:49 +0000
committerWarren Hunt <whunt@google.com>2013-12-06 20:16:49 +0000
commit71140d68f8f4ac2eb714af2de776eb1682bc4e29 (patch)
tree83d86df40390a2083f2f0f5400c3ef5ed4a2b9c5 /clang/lib/AST/RecordLayoutBuilder.cpp
parent1a68f2383fba6cee183ac535341a0d823fa76a27 (diff)
downloadbcm5719-llvm-71140d68f8f4ac2eb714af2de776eb1682bc4e29.tar.gz
bcm5719-llvm-71140d68f8f4ac2eb714af2de776eb1682bc4e29.zip
[MS-ABI] adds padding before all vbases after a bitfield
MS-ABI adds padding before *every* vbase if the last field in a record is a bit-field. This changes clangs behavior to match. I also fix some windows-style line endings in the test file. Differential Revision: http://llvm-reviews.chandlerc.com/D2277 llvm-svn: 196605
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp15
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));
}
}
OpenPOWER on IntegriCloud