diff options
author | Warren Hunt <whunt@google.com> | 2014-01-14 00:31:30 +0000 |
---|---|---|
committer | Warren Hunt <whunt@google.com> | 2014-01-14 00:31:30 +0000 |
commit | 6eba90710273be713b1f2736ce6d9c97bcf2f8be (patch) | |
tree | 1fff8a75dbf373f1d77b3666231d78845303312b /clang/lib/AST/RecordLayoutBuilder.cpp | |
parent | ca9e99fe50cefd6854755a99d3764a4bc7927de3 (diff) | |
download | bcm5719-llvm-6eba90710273be713b1f2736ce6d9c97bcf2f8be.tar.gz bcm5719-llvm-6eba90710273be713b1f2736ce6d9c97bcf2f8be.zip |
[ms-abi] Report VBPtrOffset correctly
Although VBPtrs were being placed correctly by the ms-abi layout engine,
their offsets were being improperly reported to the ASTRecordLayout
builder due to a bug. This patch fixes that and fixes the test cases to
use the correct values.
y
llvm-svn: 199168
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r-- | clang/lib/AST/RecordLayoutBuilder.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index fd0a4630125..6b3a431da21 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -2341,6 +2341,10 @@ MicrosoftRecordLayoutBuilder::layoutNonVirtualBases(const CXXRecordDecl *RD) { // Set our VBPtroffset if we know it at this point. if (!HasVBPtr) VBPtrOffset = CharUnits::fromQuantity(-1); + else if (SharedVBPtrBase) { + const ASTRecordLayout &Layout = Context.getASTRecordLayout(SharedVBPtrBase); + VBPtrOffset = Bases[SharedVBPtrBase] + Layout.getVBPtrOffset(); + } } void MicrosoftRecordLayoutBuilder::layoutNonVirtualBase( @@ -2444,13 +2448,8 @@ MicrosoftRecordLayoutBuilder::layoutZeroWidthBitField(const FieldDecl *FD) { } void MicrosoftRecordLayoutBuilder::injectVBPtr(const CXXRecordDecl *RD) { - if (!HasVBPtr) + if (!HasVBPtr || SharedVBPtrBase) return; - if (SharedVBPtrBase) { - const ASTRecordLayout &Layout = Context.getASTRecordLayout(SharedVBPtrBase); - VBPtrOffset = Bases[SharedVBPtrBase] + Layout.getVBPtrOffset(); - return; - } // Inject the VBPointer at the injection site. CharUnits InjectionSite = VBPtrOffset; // But before we do, make sure it's properly aligned. |