From d347d226ce6a15b052e0a39a885310668ded593f Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 1 Oct 2015 22:08:02 +0000 Subject: [PATCH] Don't adjust field offsets when using external record layout. This was already being done when injecting the VBPtr, but not when injecting the VFPtr. This fixes a number of tests in LLDB's test suite. Reviewed by: David Majnemer Differential Revision: http://reviews.llvm.org/D13276 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249085 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/RecordLayoutBuilder.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp index 630d780b76..0c76838a6d 100644 --- a/lib/AST/RecordLayoutBuilder.cpp +++ b/lib/AST/RecordLayoutBuilder.cpp @@ -2667,13 +2667,20 @@ void MicrosoftRecordLayoutBuilder::injectVFPtr(const CXXRecordDecl *RD) { // alignment. CharUnits Offset = PointerInfo.Size.RoundUpToAlignment( std::max(RequiredAlignment, Alignment)); - // Increase the size of the object and push back all fields, the vbptr and all - // bases by the offset amount. + // Push back the vbptr, but increase the size of the object and push back + // regular fields by the offset only if not using external record layout. + if (HasVBPtr) + VBPtrOffset += Offset; + + if (UseExternalLayout) + return; + Size += Offset; + + // If we're using an external layout, the fields offsets have already + // accounted for this adjustment. for (uint64_t &FieldOffset : FieldOffsets) FieldOffset += Context.toBits(Offset); - if (HasVBPtr) - VBPtrOffset += Offset; for (BaseOffsetsMapTy::value_type &Base : Bases) Base.second += Offset; } -- 2.40.0