[PATCH] D83008: Fix ItaniumRecordLayoutBuilder so that is grabs the correct bases class offsets from the external source
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 15:04:19 PDT 2020
shafik updated this revision to Diff 276229.
shafik marked 5 inline comments as done.
shafik added a comment.
- Removing spurious local variables in test
- Simplifying the test
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83008/new/
https://reviews.llvm.org/D83008
Files:
clang/lib/AST/RecordLayoutBuilder.cpp
lldb/test/Shell/Expr/Inputs/layout.cpp
lldb/test/Shell/Expr/TestLayoutNonVirtualBaseClasses.test
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
Index: lldb/test/Shell/Expr/Inputs/layout.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Expr/Inputs/layout.cpp
@@ -0,0 +1,17 @@
+#include <cstdint>
+
+struct B1 {
+ char f1;
+};
+
+struct alignas(8) B2 {
+ char f2;
+};
+
+struct D : B1, B2 {
+};
+
+D d3g;
+
+int main() {
+}
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83008.276229.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200707/66a9fcb6/attachment.bin>
More information about the cfe-commits
mailing list