aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-12-01 00:37:01 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-12-01 00:37:01 +0000
commit901dd668931a70932ad09092959c42693409a3cd (patch)
tree4e1dad61925e59d3bb76b47d051e62952b35d76c /lib
parent8374eda250c1cf6aede92eca289759f5e0a6c308 (diff)
Fix MSVC class layout for empty classes. Patch by Dmitry Sokolov.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145544 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/RecordLayoutBuilder.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index 60a7c2d1fe..88a90a4172 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -1399,10 +1399,8 @@ void RecordLayoutBuilder::Layout(const CXXRecordDecl *RD) {
}
// Finally, round the size of the total struct up to the alignment
- // of the struct itself. Amazingly, this does not occur in the MS
- // ABI after virtual base layout.
- if (!isMicrosoftCXXABI() || RD->getNumVBases())
- FinishLayout(RD);
+ // of the struct itself.
+ FinishLayout(RD);
#ifndef NDEBUG
// Check that we have base offsets for all bases.
@@ -1882,6 +1880,13 @@ void RecordLayoutBuilder::FinishLayout(const NamedDecl *D) {
else
setSize(CharUnits::One());
}
+
+ // MSVC doesn't round up to the alignment of the record with virtual bases.
+ if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
+ if (isMicrosoftCXXABI() && RD->getNumVBases())
+ return;
+ }
+
// Finally, round the size of the record up to the alignment of the
// record itself.
uint64_t UnpaddedSize = getSizeInBits() - UnfilledBitsInLastByte;