• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>&1 \
2 // RUN:            | FileCheck %s
3 // RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple x86_64-pc-win32 -fdump-record-layouts -fsyntax-only %s 2>/dev/null \
4 // RUN:            | FileCheck %s -check-prefix CHECK-X64
5 
6 struct B0 { int a; };
7 struct B1 { int a; };
8 
9 struct A : virtual B0 { char a : 1; };
10 
11 // CHECK: *** Dumping AST Record Layout
12 // CHECK: *** Dumping AST Record Layout
13 // CHECK-NEXT:    0 | struct A
14 // CHECK-NEXT:    0 |   (A vbtable pointer)
15 // CHECK-NEXT:    4:0-0 |   char a
16 // CHECK-NEXT:    8 |   struct B0 (virtual base)
17 // CHECK-NEXT:    8 |     int a
18 // CHECK-NEXT:      | [sizeof=12, align=4
19 // CHECK-NEXT:      |  nvsize=8, nvalign=4]
20 // CHECK-X64: *** Dumping AST Record Layout
21 // CHECK-X64: *** Dumping AST Record Layout
22 // CHECK-X64-NEXT:    0 | struct A
23 // CHECK-X64-NEXT:    0 |   (A vbtable pointer)
24 // CHECK-X64-NEXT:    8:0-0 |   char a
25 // CHECK-X64-NEXT:   16 |   struct B0 (virtual base)
26 // CHECK-X64-NEXT:   16 |     int a
27 // CHECK-X64-NEXT:      | [sizeof=24, align=8
28 // CHECK-X64-NEXT:      |  nvsize=16, nvalign=8]
29 
30 struct B : virtual B0 { short a : 1; };
31 
32 // CHECK: *** Dumping AST Record Layout
33 // CHECK-NEXT:    0 | struct B
34 // CHECK-NEXT:    0 |   (B vbtable pointer)
35 // CHECK-NEXT:    4:0-0 |   short a
36 // CHECK-NEXT:    8 |   struct B0 (virtual base)
37 // CHECK-NEXT:    8 |     int a
38 // CHECK-NEXT:      | [sizeof=12, align=4
39 // CHECK-NEXT:      |  nvsize=8, nvalign=4]
40 // CHECK-X64: *** Dumping AST Record Layout
41 // CHECK-X64-NEXT:    0 | struct B
42 // CHECK-X64-NEXT:    0 |   (B vbtable pointer)
43 // CHECK-X64-NEXT:    8:0-0 |   short a
44 // CHECK-X64-NEXT:   16 |   struct B0 (virtual base)
45 // CHECK-X64-NEXT:   16 |     int a
46 // CHECK-X64-NEXT:      | [sizeof=24, align=8
47 // CHECK-X64-NEXT:      |  nvsize=16, nvalign=8]
48 
49 struct C : virtual B0 { char a : 1; char : 0; };
50 
51 // CHECK: *** Dumping AST Record Layout
52 // CHECK-NEXT:    0 | struct C
53 // CHECK-NEXT:    0 |   (C vbtable pointer)
54 // CHECK-NEXT:    4:0-0 |   char a
55 // CHECK-NEXT:    5:- |   char
56 // CHECK-NEXT:    8 |   struct B0 (virtual base)
57 // CHECK-NEXT:    8 |     int a
58 // CHECK-NEXT:      | [sizeof=12, align=4
59 // CHECK-NEXT:      |  nvsize=8, nvalign=4]
60 // CHECK-X64: *** Dumping AST Record Layout
61 // CHECK-X64-NEXT:    0 | struct C
62 // CHECK-X64-NEXT:    0 |   (C vbtable pointer)
63 // CHECK-X64-NEXT:    8:0-0 |   char a
64 // CHECK-X64-NEXT:    9:- |   char
65 // CHECK-X64-NEXT:   16 |   struct B0 (virtual base)
66 // CHECK-X64-NEXT:   16 |     int a
67 // CHECK-X64-NEXT:      | [sizeof=24, align=8
68 // CHECK-X64-NEXT:      |  nvsize=16, nvalign=8]
69 
70 struct D : virtual B0 { char a : 1; char b; };
71 
72 // CHECK: *** Dumping AST Record Layout
73 // CHECK-NEXT:    0 | struct D
74 // CHECK-NEXT:    0 |   (D vbtable pointer)
75 // CHECK-NEXT:    4:0-0 |   char a
76 // CHECK-NEXT:    5 |   char b
77 // CHECK-NEXT:    8 |   struct B0 (virtual base)
78 // CHECK-NEXT:    8 |     int a
79 // CHECK-NEXT:      | [sizeof=12, align=4
80 // CHECK-NEXT:      |  nvsize=8, nvalign=4]
81 // CHECK-X64: *** Dumping AST Record Layout
82 // CHECK-X64-NEXT:    0 | struct D
83 // CHECK-X64-NEXT:    0 |   (D vbtable pointer)
84 // CHECK-X64-NEXT:    8:0-0 |   char a
85 // CHECK-X64-NEXT:    9 |   char b
86 // CHECK-X64-NEXT:   16 |   struct B0 (virtual base)
87 // CHECK-X64-NEXT:   16 |     int a
88 // CHECK-X64-NEXT:      | [sizeof=24, align=8
89 // CHECK-X64-NEXT:      |  nvsize=16, nvalign=8]
90 
91 struct E : virtual B0, virtual B1 { long long : 1; };
92 // CHECK: *** Dumping AST Record Layout
93 // CHECK: *** Dumping AST Record Layout
94 // CHECK-NEXT:    0 | struct E
95 // CHECK-NEXT:    0 |   (E vbtable pointer)
96 // CHECK-NEXT:    8:0-0 |   long long
97 // CHECK-NEXT:   16 |   struct B0 (virtual base)
98 // CHECK-NEXT:   16 |     int a
99 // CHECK-NEXT:   20 |   struct B1 (virtual base)
100 // CHECK-NEXT:   20 |     int a
101 // CHECK-NEXT:      | [sizeof=24, align=8
102 // CHECK-NEXT:      |  nvsize=16, nvalign=8]
103 // CHECK-X64: *** Dumping AST Record Layout
104 // CHECK-X64: *** Dumping AST Record Layout
105 // CHECK-X64-NEXT:    0 | struct E
106 // CHECK-X64-NEXT:    0 |   (E vbtable pointer)
107 // CHECK-X64-NEXT:    8:0-0 |   long long
108 // CHECK-X64-NEXT:   16 |   struct B0 (virtual base)
109 // CHECK-X64-NEXT:   16 |     int a
110 // CHECK-X64-NEXT:   20 |   struct B1 (virtual base)
111 // CHECK-X64-NEXT:   20 |     int a
112 // CHECK-X64-NEXT:      | [sizeof=24, align=8
113 // CHECK-X64-NEXT:      |  nvsize=16, nvalign=8]
114 
115 int a[
116 sizeof(A)+
117 sizeof(B)+
118 sizeof(C)+
119 sizeof(D)+
120 sizeof(E)];
121