summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/override-layout.cpp
diff options
context:
space:
mode:
authorAleksandr Urakov <aleksandr.urakov@jetbrains.com>2019-03-13 13:38:12 +0000
committerAleksandr Urakov <aleksandr.urakov@jetbrains.com>2019-03-13 13:38:12 +0000
commit867c2a7d369c6a067cadead7cd94ad5b391f14b4 (patch)
treef89c44f8aeecdfca51685cda3d31190d3d8c1c83 /clang/test/CodeGenCXX/override-layout.cpp
parent0c1e5aacd35f42fdce2fdacb0e278d7879caf529 (diff)
downloadbcm5719-llvm-867c2a7d369c6a067cadead7cd94ad5b391f14b4.tar.gz
bcm5719-llvm-867c2a7d369c6a067cadead7cd94ad5b391f14b4.zip
[AST] Improve support of external layouts in `MicrosoftRecordLayoutBuilder`
Summary: This patch fixes several small problems with external layouts support in `MicrosoftRecordLayoutBuilder`: - aligns properly the size of a struct that ends with a bit field. It was aligned on byte before, not on the size of the field, so the struct size was smaller than it should be; - adjusts the struct size when injecting a vbptr in the case when there were no bases or fields allocated after the vbptr. Similarly, without the adjustment the struct was smaller than it should be; - the same fix as above for the vfptr. All these fixes affect the non-virtual size of a struct, so they are tested through non-virtual inheritance. Reviewers: rnk, zturner, rsmith Reviewed By: rnk Subscribers: jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58544 llvm-svn: 356047
Diffstat (limited to 'clang/test/CodeGenCXX/override-layout.cpp')
-rw-r--r--clang/test/CodeGenCXX/override-layout.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/override-layout.cpp b/clang/test/CodeGenCXX/override-layout.cpp
index a3c4bb446ca..fea2a45c629 100644
--- a/clang/test/CodeGenCXX/override-layout.cpp
+++ b/clang/test/CodeGenCXX/override-layout.cpp
@@ -64,6 +64,23 @@ struct PACKED X5 {
short r;
};
+// CHECK: Type: struct X6
+struct __attribute__((aligned(16))) X6 {
+ int x;
+ int y;
+ virtual ~X6();
+};
+
+// CHECK: Type: struct X7
+struct X7 {
+ int z;
+};
+
+// CHECK: Type: struct X8
+struct X8 : X6, virtual X7 {
+ char c;
+};
+
void use_structs() {
X0 x0s[sizeof(X0)];
X1 x1s[sizeof(X1)];
@@ -71,7 +88,9 @@ void use_structs() {
X3 x3s[sizeof(X3)];
X4 x4s[sizeof(X4)];
X5 x5s[sizeof(X5)];
+ X6 x6s[sizeof(X6)];
+ X7 x7s[sizeof(X7)];
+ X8 x8s[sizeof(X8)];
x4s[1].a = 1;
x5s[1].a = 17;
}
-
OpenPOWER on IntegriCloud