summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
diff options
context:
space:
mode:
authorAleksandr Urakov <aleksandr.urakov@jetbrains.com>2018-07-31 08:27:06 +0000
committerAleksandr Urakov <aleksandr.urakov@jetbrains.com>2018-07-31 08:27:06 +0000
commit09240ef77639785a8207e636796cb2fb7c73c3fb (patch)
treefc79c0c1e7773301227bc5b7e332913c9807c828 /clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
parent615540d0f27b25f5f8761b6319548faf5f9084a3 (diff)
downloadbcm5719-llvm-09240ef77639785a8207e636796cb2fb7c73c3fb.tar.gz
bcm5719-llvm-09240ef77639785a8207e636796cb2fb7c73c3fb.zip
Improve support of PDB as an external layout source
Summary: This patch improves support of PDB as an external layout source in the next cases: - Multiple non-virtual inheritance from packed base classes. When using external layout, there's no need to align `NonVirtualSize` of a base class. It may cause an overlapping when the next base classes will be layouted (but there is a slightly different case in the test because I can't find a way to specify a base offset); - Support of nameless structs and unions. There is no info about nameless child structs and unions in Microsoft cl-emitted PDBs. Instead all its fields are just treated as outer structure's (union's) fields. This also causes a fields overlapping, and makes it possible for unions to have fields located at a non-zero offset. Reviewers: rsmith, zturner, rnk, mstorsjo, majnemer Reviewed By: rnk Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D49871 llvm-svn: 338353
Diffstat (limited to 'clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp')
-rw-r--r--clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp b/clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
new file mode 100644
index 00000000000..acc1ff715c6
--- /dev/null
+++ b/clang/test/CodeGenCXX/override-layout-nameless-struct-union.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -w -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-layout-nameless-struct-union.layout %s | FileCheck %s
+
+// CHECK: Type: struct S
+// CHECK: Size:64
+// CHECK: Alignment:32
+// CHECK: FieldOffsets: [0, 32, 32]
+struct S {
+ short _s;
+//union {
+ int _su0;
+ char _su1;
+//};
+};
+
+// CHECK: Type: union U
+// CHECK: Size:96
+// CHECK: Alignment:32
+// CHECK: FieldOffsets: [0, 0, 32, 64, 68, 73]
+union U {
+ short _u;
+//struct {
+ char _us0;
+ int _us1;
+ unsigned _us20 : 4;
+ unsigned _us21 : 5;
+ unsigned _us22 : 6;
+//};
+};
+
+void use_structs() {
+ S ss[sizeof(S)];
+ U us[sizeof(U)];
+}
OpenPOWER on IntegriCloud