]> granicus.if.org Git - clang/commitdiff
Don't adjust field offsets when using external record layout.
authorZachary Turner <zturner@google.com>
Thu, 1 Oct 2015 22:08:02 +0000 (22:08 +0000)
committerZachary Turner <zturner@google.com>
Thu, 1 Oct 2015 22:08:02 +0000 (22:08 +0000)
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

index 630d780b764d2a6b3a01d47ec1459c2d0165ee70..0c76838a6d21b6d89bee2604283acbd9b2796b66 100644 (file)
@@ -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;
 }