diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-12-01 00:37:01 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-12-01 00:37:01 +0000 |
| commit | 83a125834252ab885efc6784bb1146f5ed753487 (patch) | |
| tree | 259abc90629f1fb10910cfe9f169273ba93b54e3 /clang/lib/AST | |
| parent | dc82cca6bfd1c117556d718e71a7f6cbf65032fb (diff) | |
| download | bcm5719-llvm-83a125834252ab885efc6784bb1146f5ed753487.tar.gz bcm5719-llvm-83a125834252ab885efc6784bb1146f5ed753487.zip | |
Fix MSVC class layout for empty classes. Patch by Dmitry Sokolov.
llvm-svn: 145544
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 60a7c2d1fe7..88a90a41729 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/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; |

