mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 16:46:06 +00:00

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
22 lines
440 B
C++
22 lines
440 B
C++
// RUN: %clang_cc1 -w -triple=x86_64-pc-win32 -fms-compatibility -fdump-record-layouts-simple -foverride-record-layout=%S/Inputs/override-layout-virtual-base.layout %s | FileCheck %s
|
|
|
|
struct S1 {
|
|
int a;
|
|
};
|
|
|
|
struct S2 : virtual S1 {
|
|
virtual void foo() {}
|
|
};
|
|
|
|
// CHECK: Type: struct S3
|
|
// CHECK: FieldOffsets: [128]
|
|
struct S3 : S2 {
|
|
char b;
|
|
};
|
|
|
|
void use_structs() {
|
|
S1 s1s[sizeof(S1)];
|
|
S2 s2s[sizeof(S2)];
|
|
S3 s3s[sizeof(S3)];
|
|
}
|