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,17 @@ +#include + +struct B1 { + char f1; +}; + +struct alignas(8) B2 { + char f2; +}; + +struct D : B1, B2 { +}; + +D d3g; + +int main() { +} Index: lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test =================================================================== --- /dev/null +++ lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test @@ -0,0 +1,7 @@ +# RUN: %clangxx_host %p/Inputs/layout.cpp -g -o %t + +# RUN: %lldb %t -b -s %s | FileCheck %s + +expr (intptr_t)&d3g.f2 - (intptr_t)&d3g +# CHECK: (lldb) expr (intptr_t)&d3g.f2 - (intptr_t)&d3g +# CHECK: (long) $0 = 8