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

llvm-svn: 249085
This commit is contained in:
Zachary Turner 2015-10-01 22:08:02 +00:00
parent f0672f1187
commit f686a445db
1 changed files with 12 additions and 5 deletions

View 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.
Size += Offset;
for (uint64_t &FieldOffset : FieldOffsets)
FieldOffset += Context.toBits(Offset);
// 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);
for (BaseOffsetsMapTy::value_type &Base : Bases)
Base.second += Offset;
}