Index: clang/lib/AST/RecordLayoutBuilder.cpp =================================================================== --- clang/lib/AST/RecordLayoutBuilder.cpp +++ clang/lib/AST/RecordLayoutBuilder.cpp @@ -1187,11 +1187,10 @@ // Query the external layout to see if it provides an offset. bool HasExternalLayout = false; if (UseExternalLayout) { - // FIXME: This appears to be reversed. if (Base->IsVirtual) - HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset); - else HasExternalLayout = External.getExternalVBaseOffset(Base->Class, Offset); + else + HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset); } // Clang <= 6 incorrectly applied the 'packed' attribute to base classes. Index: lldb/test/Shell/Expr/Inputs/layout.cpp =================================================================== --- /dev/null +++ lldb/test/Shell/Expr/Inputs/layout.cpp @@ -0,0 +1,43 @@ +#include + +struct B1 { + uint8_t a; +}; + +struct D1 : public B1 { + uint8_t a; + uint32_t ID; + uint8_t b; +}; + +struct Mixin : public D1 { + uint8_t a; + uint32_t *arr[3]; +}; + +struct B2 { + uint32_t a; +}; + +class D2 : public B2, public Mixin {}; + +struct B3 { + char f1; +}; + +struct alignas(8) B4 { + char f2; +}; + +struct D3 : B3, B4 { +}; + +D2 d2g; +D3 d3g; + +int main() { + D2 d2; + D3 d3; + + return d2.ID + d3.f2; +} Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test =================================================================== --- /dev/null +++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test @@ -0,0 +1,11 @@ +# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t + +# RUN: %lldb %t -b -s %s | FileCheck %s + +expr (intptr_t)&d2g.ID - (intptr_t)&d2g +# CHECK: (lldb) expr (intptr_t)&d2g.ID - (intptr_t)&d2g +# CHECK: (long) $0 = 12 + +expr (intptr_t)&d3g.f2 - (intptr_t)&d3g +# CHECK: (lldb) expr (intptr_t)&d3g.f2 - (intptr_t)&d3g +# CHECK: (long) $1 = 8