[PATCH] D13276: Don't adjust field offsets for external record layouts

Zachary Turner via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 17:24:43 PDT 2015


zturner created this revision.
zturner added a reviewer: majnemer.
zturner added a subscriber: cfe-commits.

injecting the VBPtr always behaves this way, but injecting the VFPtr was not.  This patch fixes that.

http://reviews.llvm.org/D13276

Files:
  lib/AST/RecordLayoutBuilder.cpp

Index: lib/AST/RecordLayoutBuilder.cpp
===================================================================
--- lib/AST/RecordLayoutBuilder.cpp
+++ lib/AST/RecordLayoutBuilder.cpp
@@ -2667,13 +2667,21 @@
   // 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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13276.36054.patch
Type: text/x-patch
Size: 1040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150930/4ee17a40/attachment.bin>


More information about the cfe-commits mailing list