summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/override-bit-field-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-bit-field-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-bit-field-layout.cpp')
-rw-r--r--clang/test/CodeGenCXX/override-bit-field-layout.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/override-bit-field-layout.cpp b/clang/test/CodeGenCXX/override-bit-field-layout.cpp
index e84fcb0f450..dee7944f6a5 100644
--- a/clang/test/CodeGenCXX/override-bit-field-layout.cpp
+++ b/clang/test/CodeGenCXX/override-bit-field-layout.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -w -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s
+// RUN: %clang_cc1 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-bit-field-layout.layout %s | FileCheck %s
// CHECK: Type: struct S1
// CHECK: FieldOffsets: [0, 11]
@@ -14,7 +14,23 @@ struct S2 {
short a : 3;
};
+// CHECK: Type: struct S3
+// CHECK: Size:32
+// CHECK: FieldOffsets: [0, 1]
+struct S3 {
+ int a : 1;
+ int b : 2;
+};
+
+// CHECK: Type: struct S4
+// CHECK: FieldOffsets: [32]
+struct S4 : S3 {
+ char c;
+};
+
void use_structs() {
S1 s1s[sizeof(S1)];
S2 s2s[sizeof(S2)];
+ S3 s3s[sizeof(S3)];
+ S4 s4s[sizeof(S4)];
}
OpenPOWER on IntegriCloud