2013-12-06 08:01:17 +08:00
|
|
|
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -cxx-abi microsoft %s 2>&1 \
|
|
|
|
// RUN: | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only -cxx-abi microsoft %s 2>/dev/null \
|
|
|
|
// RUN: | FileCheck %s -check-prefix CHECK-X64
|
|
|
|
|
|
|
|
extern "C" int printf(const char *fmt, ...);
|
|
|
|
char buffer[419430400];
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
char a;
|
|
|
|
A() {
|
|
|
|
printf("A = %d\n", (int)((char*)this - buffer));
|
|
|
|
printf("A.a = %d\n", (int)((char*)&a - buffer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
__declspec(align(4)) long long a;
|
|
|
|
B() {
|
|
|
|
printf("B = %d\n", (int)((char*)this - buffer));
|
|
|
|
printf("B.a = %d\n", (int)((char*)&a - buffer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(push, 2)
|
|
|
|
struct X {
|
|
|
|
B a;
|
|
|
|
char b;
|
|
|
|
int c;
|
|
|
|
X() {
|
|
|
|
printf("X = %d\n", (int)((char*)this - buffer));
|
|
|
|
printf("X.a = %d\n", (int)((char*)&a - buffer));
|
|
|
|
printf("X.b = %d\n", (int)((char*)&b - buffer));
|
|
|
|
printf("X.c = %d\n", (int)((char*)&c - buffer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct X
|
|
|
|
// CHECK-NEXT: 0 | struct B a
|
|
|
|
// CHECK-NEXT: 0 | long long a
|
|
|
|
// CHECK: 8 | char b
|
|
|
|
// CHECK-NEXT: 10 | int c
|
|
|
|
// CHECK-NEXT: | [sizeof=16, align=4
|
|
|
|
// CHECK-NEXT: | nvsize=16, nvalign=4]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
2013-12-06 08:01:17 +08:00
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK-X64-NEXT: 0 | struct X
|
|
|
|
// CHECK-X64-NEXT: 0 | struct B a
|
|
|
|
// CHECK-X64-NEXT: 0 | long long a
|
|
|
|
// CHECK-X64: 8 | char b
|
|
|
|
// CHECK-X64-NEXT: 10 | int c
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=16, align=4
|
|
|
|
// CHECK-X64-NEXT: | nvsize=16, nvalign=4]
|
2013-12-06 08:01:17 +08:00
|
|
|
|
|
|
|
struct Y : A, B {
|
|
|
|
char a;
|
|
|
|
int b;
|
|
|
|
Y() {
|
|
|
|
printf("Y = %d\n", (int)((char*)this - buffer));
|
|
|
|
printf("Y.a = %d\n", (int)((char*)&a - buffer));
|
|
|
|
printf("Y.b = %d\n", (int)((char*)&b - buffer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct Y
|
|
|
|
// CHECK-NEXT: 0 | struct A (base)
|
|
|
|
// CHECK-NEXT: 0 | char a
|
|
|
|
// CHECK-NEXT: 4 | struct B (base)
|
|
|
|
// CHECK-NEXT: 4 | long long a
|
|
|
|
// CHECK-NEXT: 12 | char a
|
|
|
|
// CHECK-NEXT: 14 | int b
|
|
|
|
// CHECK-NEXT: | [sizeof=20, align=4
|
|
|
|
// CHECK-NEXT: | nvsize=20, nvalign=4]
|
2013-12-06 08:01:17 +08:00
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct Y
|
|
|
|
// CHECK-X64-NEXT: 0 | struct A (base)
|
|
|
|
// CHECK-X64-NEXT: 0 | char a
|
|
|
|
// CHECK-X64-NEXT: 4 | struct B (base)
|
|
|
|
// CHECK-X64-NEXT: 4 | long long a
|
|
|
|
// CHECK-X64-NEXT: 12 | char a
|
|
|
|
// CHECK-X64-NEXT: 14 | int b
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=20, align=4
|
|
|
|
// CHECK-X64-NEXT: | nvsize=20, nvalign=4]
|
2013-12-06 08:01:17 +08:00
|
|
|
|
|
|
|
struct Z : virtual B {
|
|
|
|
char a;
|
|
|
|
int b;
|
|
|
|
Z() {
|
|
|
|
printf("Z = %d\n", (int)((char*)this - buffer));
|
|
|
|
printf("Z.a = %d\n", (int)((char*)&a - buffer));
|
|
|
|
printf("Z.b = %d\n", (int)((char*)&b - buffer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK-NEXT: 0 | struct Z
|
|
|
|
// CHECK-NEXT: 0 | (Z vbtable pointer)
|
|
|
|
// CHECK-NEXT: 4 | char a
|
|
|
|
// CHECK-NEXT: 6 | int b
|
|
|
|
// CHECK-NEXT: 12 | struct B (virtual base)
|
|
|
|
// CHECK-NEXT: 12 | long long a
|
|
|
|
// CHECK-NEXT: | [sizeof=20, align=4
|
|
|
|
// CHECK-NEXT: | nvsize=10, nvalign=4]
|
2013-12-06 08:01:17 +08:00
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK-X64-NEXT: 0 | struct Z
|
|
|
|
// CHECK-X64-NEXT: 0 | (Z vbtable pointer)
|
|
|
|
// CHECK-X64-NEXT: 8 | char a
|
|
|
|
// CHECK-X64-NEXT: 10 | int b
|
|
|
|
// CHECK-X64-NEXT: 16 | struct B (virtual base)
|
|
|
|
// CHECK-X64-NEXT: 16 | long long a
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=24, align=4
|
|
|
|
// CHECK-X64-NEXT: | nvsize=14, nvalign=4]
|
2013-12-06 08:01:17 +08:00
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
2013-12-11 10:21:03 +08:00
|
|
|
struct A1 { long long a; };
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct B1 : virtual A1 { char a; };
|
|
|
|
#pragma pack(pop)
|
|
|
|
struct C1 : B1 {};
|
2013-12-27 06:09:12 +08:00
|
|
|
|
2013-12-11 10:21:03 +08:00
|
|
|
// CHECK: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct C1
|
|
|
|
// CHECK-NEXT: 0 | struct B1 (base)
|
|
|
|
// CHECK-NEXT: 0 | (B1 vbtable pointer)
|
|
|
|
// CHECK-NEXT: 4 | char a
|
|
|
|
// CHECK-NEXT: 8 | struct A1 (virtual base)
|
|
|
|
// CHECK-NEXT: 8 | long long a
|
|
|
|
// CHECK-NEXT: | [sizeof=16, align=8
|
|
|
|
// CHECK-NEXT: | nvsize=5, nvalign=8]
|
2013-12-11 10:21:03 +08:00
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct C1
|
|
|
|
// CHECK-X64-NEXT: 0 | struct B1 (base)
|
|
|
|
// CHECK-X64-NEXT: 0 | (B1 vbtable pointer)
|
|
|
|
// CHECK-X64-NEXT: 8 | char a
|
|
|
|
// CHECK-X64-NEXT: 16 | struct A1 (virtual base)
|
|
|
|
// CHECK-X64-NEXT: 16 | long long a
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=24, align=8
|
|
|
|
// CHECK-X64-NEXT: | nvsize=9, nvalign=8]
|
2013-12-11 10:21:03 +08:00
|
|
|
|
2013-12-27 06:09:12 +08:00
|
|
|
struct CA0 {
|
|
|
|
CA0() {}
|
|
|
|
};
|
|
|
|
struct CA1 : virtual CA0 {
|
|
|
|
CA1() {}
|
|
|
|
};
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct CA2 : public CA1, public CA0 {
|
|
|
|
virtual void CA2Method() {}
|
|
|
|
CA2() {}
|
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct CA2
|
|
|
|
// CHECK-NEXT: 0 | (CA2 vftable pointer)
|
|
|
|
// CHECK-NEXT: 4 | struct CA1 (base)
|
|
|
|
// CHECK-NEXT: 4 | (CA1 vbtable pointer)
|
|
|
|
// CHECK-NEXT: 9 | struct CA0 (base) (empty)
|
|
|
|
// CHECK-NEXT: 9 | struct CA0 (virtual base) (empty)
|
|
|
|
// CHECK-NEXT: | [sizeof=9, align=1
|
|
|
|
// CHECK-NEXT: | nvsize=9, nvalign=1]
|
|
|
|
// CHECK-C64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-C64: *** Dumping AST Record Layout
|
2013-12-27 06:09:12 +08:00
|
|
|
// CHECK-C64: *** Dumping AST Record Layout
|
2014-01-09 08:30:56 +08:00
|
|
|
// CHECK-C64-NEXT: 0 | struct CA2
|
|
|
|
// CHECK-C64-NEXT: 0 | (CA2 vftable pointer)
|
|
|
|
// CHECK-C64-NEXT: 8 | struct CA1 (base)
|
|
|
|
// CHECK-C64-NEXT: 8 | (CA1 vbtable pointer)
|
|
|
|
// CHECK-C64-NEXT: 17 | struct CA0 (base) (empty)
|
|
|
|
// CHECK-C64-NEXT: 17 | struct CA0 (virtual base) (empty)
|
|
|
|
// CHECK-C64-NEXT: | [sizeof=17, align=1
|
|
|
|
// CHECK-C64-NEXT: | nvsize=17, nvalign=1]
|
2013-12-27 06:09:12 +08:00
|
|
|
|
2014-01-10 09:28:05 +08:00
|
|
|
#pragma pack(16)
|
|
|
|
struct YA {
|
|
|
|
__declspec(align(32)) char : 1;
|
|
|
|
};
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct YA (empty)
|
|
|
|
// CHECK-NEXT: 0 | char
|
|
|
|
// CHECK-NEXT: | [sizeof=32, align=32
|
|
|
|
// CHECK-NEXT: | nvsize=32, nvalign=32]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct YA (empty)
|
|
|
|
// CHECK-X64-NEXT: 0 | char
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=32, align=32
|
|
|
|
// CHECK-X64-NEXT: | nvsize=32, nvalign=32]
|
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
struct YB {
|
|
|
|
char a;
|
|
|
|
YA b;
|
|
|
|
};
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct YB
|
|
|
|
// CHECK-NEXT: 0 | char a
|
|
|
|
// CHECK-NEXT: 1 | struct YA b (empty)
|
|
|
|
// CHECK-NEXT: 1 | char
|
|
|
|
// CHECK: | [sizeof=33, align=1
|
|
|
|
// CHECK-NEXT: | nvsize=33, nvalign=1]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct YB
|
|
|
|
// CHECK-X64-NEXT: 0 | char a
|
|
|
|
// CHECK-X64-NEXT: 1 | struct YA b (empty)
|
|
|
|
// CHECK-X64-NEXT: 1 | char
|
|
|
|
// CHECK-X64: | [sizeof=33, align=1
|
|
|
|
// CHECK-X64-NEXT: | nvsize=33, nvalign=1]
|
|
|
|
|
|
|
|
#pragma pack(8)
|
|
|
|
struct YC {
|
|
|
|
__declspec(align(32)) char : 1;
|
|
|
|
};
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct YC (empty)
|
|
|
|
// CHECK-NEXT: 0 | char
|
|
|
|
// CHECK-NEXT: | [sizeof=32, align=32
|
|
|
|
// CHECK-NEXT: | nvsize=32, nvalign=32]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct YC (empty)
|
|
|
|
// CHECK-X64-NEXT: 0 | char
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=8, align=8
|
|
|
|
// CHECK-X64-NEXT: | nvsize=8, nvalign=8]
|
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
struct YD {
|
|
|
|
char a;
|
|
|
|
YC b;
|
|
|
|
};
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct YD
|
|
|
|
// CHECK-NEXT: 0 | char a
|
|
|
|
// CHECK-NEXT: 1 | struct YC b (empty)
|
|
|
|
// CHECK-NEXT: 1 | char
|
|
|
|
// CHECK: | [sizeof=33, align=1
|
|
|
|
// CHECK-NEXT: | nvsize=33, nvalign=1]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct YD
|
|
|
|
// CHECK-X64-NEXT: 0 | char a
|
|
|
|
// CHECK-X64-NEXT: 1 | struct YC b (empty)
|
|
|
|
// CHECK-X64-NEXT: 1 | char
|
|
|
|
// CHECK-X64: | [sizeof=9, align=1
|
|
|
|
// CHECK-X64-NEXT: | nvsize=9, nvalign=1]
|
|
|
|
|
|
|
|
#pragma pack(4)
|
|
|
|
struct YE {
|
|
|
|
__declspec(align(32)) char : 1;
|
|
|
|
};
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct YE (empty)
|
|
|
|
// CHECK-NEXT: 0 | char
|
|
|
|
// CHECK-NEXT: | [sizeof=4, align=4
|
|
|
|
// CHECK-NEXT: | nvsize=4, nvalign=4]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct YE (empty)
|
|
|
|
// CHECK-X64-NEXT: 0 | char
|
|
|
|
// CHECK-X64-NEXT: | [sizeof=4, align=4
|
|
|
|
// CHECK-X64-NEXT: | nvsize=4, nvalign=4]
|
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
struct YF {
|
|
|
|
char a;
|
|
|
|
YE b;
|
|
|
|
};
|
|
|
|
// CHECK: *** Dumping AST Record Layout
|
|
|
|
// CHECK-NEXT: 0 | struct YF
|
|
|
|
// CHECK-NEXT: 0 | char a
|
|
|
|
// CHECK-NEXT: 1 | struct YE b (empty)
|
|
|
|
// CHECK-NEXT: 1 | char
|
|
|
|
// CHECK: | [sizeof=5, align=1
|
|
|
|
// CHECK-NEXT: | nvsize=5, nvalign=1]
|
|
|
|
// CHECK-X64: *** Dumping AST Record Layout
|
|
|
|
// CHECK-X64-NEXT: 0 | struct YF
|
|
|
|
// CHECK-X64-NEXT: 0 | char a
|
|
|
|
// CHECK-X64-NEXT: 1 | struct YE b (empty)
|
|
|
|
// CHECK-X64-NEXT: 1 | char
|
|
|
|
// CHECK-X64: | [sizeof=5, align=1
|
|
|
|
// CHECK-X64-NEXT: | nvsize=5, nvalign=1]
|
|
|
|
|
2013-12-06 08:01:17 +08:00
|
|
|
int a[
|
|
|
|
sizeof(X)+
|
|
|
|
sizeof(Y)+
|
2013-12-11 10:21:03 +08:00
|
|
|
sizeof(Z)+
|
2013-12-27 06:09:12 +08:00
|
|
|
sizeof(C1)+
|
2014-01-10 09:28:05 +08:00
|
|
|
sizeof(CA2)+
|
|
|
|
sizeof(YA)+
|
|
|
|
sizeof(YB)+
|
|
|
|
sizeof(YC)+
|
|
|
|
sizeof(YD)+
|
|
|
|
sizeof(YE)+
|
|
|
|
sizeof(YF)+
|
|
|
|
0];
|