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 extern "C" int printf(const char *fmt, ...); 7 8 struct B0 { int a; B0() : a(0xf00000B0) { printf("B0 = %p\n", this); } }; 9 struct B1 { int a; B1() : a(0xf00000B1) { printf("B1 = %p\n", this); } }; 10 struct B2 { B2() { printf("B2 = %p\n", this); } virtual void g() { printf("B2"); } }; 11 struct B3 : virtual B1 { B3() { printf("B3 = %p\n", this); } }; 12 struct B4 : virtual B1 { B4() { printf("B4 = %p\n", this); } virtual void g() { printf("B4"); } }; 13 14 struct A : B0, virtual B1 { 15 __declspec(align(16)) int a; 16 A() : a(0xf000000A) { printf(" A = %p\n\n", this); } 17 virtual void f() { printf("A"); } 18 }; 19 20 // CHECK: *** Dumping AST Record Layout 21 // CHECK: *** Dumping AST Record Layout 22 // CHECK: *** Dumping AST Record Layout 23 // CHECK-NEXT: 0 | struct A 24 // CHECK-NEXT: 0 | (A vftable pointer) 25 // CHECK-NEXT: 16 | struct B0 (base) 26 // CHECK-NEXT: 16 | int a 27 // CHECK-NEXT: 20 | (A vbtable pointer) 28 // CHECK-NEXT: 48 | int a 29 // CHECK-NEXT: 64 | struct B1 (virtual base) 30 // CHECK-NEXT: 64 | int a 31 // CHECK-NEXT: | [sizeof=80, align=16 32 // CHECK-NEXT: | nvsize=64, nvalign=16] 33 // CHECK-X64: *** Dumping AST Record Layout 34 // CHECK-X64: *** Dumping AST Record Layout 35 // CHECK-X64: *** Dumping AST Record Layout 36 // CHECK-X64-NEXT: 0 | struct A 37 // CHECK-X64-NEXT: 0 | (A vftable pointer) 38 // CHECK-X64-NEXT: 16 | struct B0 (base) 39 // CHECK-X64-NEXT: 16 | int a 40 // CHECK-X64-NEXT: 24 | (A vbtable pointer) 41 // CHECK-X64-NEXT: 48 | int a 42 // CHECK-X64-NEXT: 64 | struct B1 (virtual base) 43 // CHECK-X64-NEXT: 64 | int a 44 // CHECK-X64-NEXT: | [sizeof=80, align=16 45 // CHECK-X64-NEXT: | nvsize=64, nvalign=16] 46 47 struct B : B2, B0, virtual B1 { 48 __declspec(align(16)) int a; 49 B() : a(0xf000000B) { printf(" B = %p\n\n", this); } 50 virtual void f() { printf("B"); } 51 }; 52 53 // CHECK: *** Dumping AST Record Layout 54 // CHECK: *** Dumping AST Record Layout 55 // CHECK-NEXT: 0 | struct B 56 // CHECK-NEXT: 0 | struct B2 (primary base) 57 // CHECK-NEXT: 0 | (B2 vftable pointer) 58 // CHECK-NEXT: 4 | struct B0 (base) 59 // CHECK-NEXT: 4 | int a 60 // CHECK-NEXT: 8 | (B vbtable pointer) 61 // CHECK-NEXT: 32 | int a 62 // CHECK-NEXT: 48 | struct B1 (virtual base) 63 // CHECK-NEXT: 48 | int a 64 // CHECK-NEXT: | [sizeof=64, align=16 65 // CHECK-NEXT: | nvsize=48, nvalign=16] 66 // CHECK-X64: *** Dumping AST Record Layout 67 // CHECK-X64: *** Dumping AST Record Layout 68 // CHECK-X64-NEXT: 0 | struct B 69 // CHECK-X64-NEXT: 0 | struct B2 (primary base) 70 // CHECK-X64-NEXT: 0 | (B2 vftable pointer) 71 // CHECK-X64-NEXT: 8 | struct B0 (base) 72 // CHECK-X64-NEXT: 8 | int a 73 // CHECK-X64-NEXT: 16 | (B vbtable pointer) 74 // CHECK-X64-NEXT: 32 | int a 75 // CHECK-X64-NEXT: 48 | struct B1 (virtual base) 76 // CHECK-X64-NEXT: 48 | int a 77 // CHECK-X64-NEXT: | [sizeof=64, align=16 78 // CHECK-X64-NEXT: | nvsize=48, nvalign=16] 79 80 struct C : B3, B0, virtual B1 { 81 __declspec(align(16)) int a; 82 C() : a(0xf000000C) { printf(" C = %p\n\n", this); } 83 virtual void f() { printf("C"); } 84 }; 85 86 // CHECK: *** Dumping AST Record Layout 87 // CHECK: *** Dumping AST Record Layout 88 // CHECK-NEXT: 0 | struct C 89 // CHECK-NEXT: 0 | (C vftable pointer) 90 // CHECK-NEXT: 16 | struct B3 (base) 91 // CHECK-NEXT: 16 | (B3 vbtable pointer) 92 // CHECK-NEXT: 20 | struct B0 (base) 93 // CHECK-NEXT: 20 | int a 94 // CHECK-NEXT: 32 | int a 95 // CHECK-NEXT: 48 | struct B1 (virtual base) 96 // CHECK-NEXT: 48 | int a 97 // CHECK-NEXT: | [sizeof=64, align=16 98 // CHECK-NEXT: | nvsize=48, nvalign=16] 99 // CHECK-X64: *** Dumping AST Record Layout 100 // CHECK-X64: *** Dumping AST Record Layout 101 // CHECK-X64-NEXT: 0 | struct C 102 // CHECK-X64-NEXT: 0 | (C vftable pointer) 103 // CHECK-X64-NEXT: 16 | struct B3 (base) 104 // CHECK-X64-NEXT: 16 | (B3 vbtable pointer) 105 // CHECK-X64-NEXT: 24 | struct B0 (base) 106 // CHECK-X64-NEXT: 24 | int a 107 // CHECK-X64-NEXT: 32 | int a 108 // CHECK-X64-NEXT: 48 | struct B1 (virtual base) 109 // CHECK-X64-NEXT: 48 | int a 110 // CHECK-X64-NEXT: | [sizeof=64, align=16 111 // CHECK-X64-NEXT: | nvsize=48, nvalign=16] 112 113 struct D : B4, B0, virtual B1 { 114 __declspec(align(16)) int a; 115 D() : a(0xf000000D) { printf(" D = %p\n\n", this); } 116 virtual void f() { printf("D"); } 117 }; 118 119 // CHECK: *** Dumping AST Record Layout 120 // CHECK: *** Dumping AST Record Layout 121 // CHECK-NEXT: 0 | struct D 122 // CHECK-NEXT: 0 | struct B4 (primary base) 123 // CHECK-NEXT: 0 | (B4 vftable pointer) 124 // CHECK-NEXT: 4 | (B4 vbtable pointer) 125 // CHECK-NEXT: 8 | struct B0 (base) 126 // CHECK-NEXT: 8 | int a 127 // CHECK-NEXT: 16 | int a 128 // CHECK-NEXT: 32 | struct B1 (virtual base) 129 // CHECK-NEXT: 32 | int a 130 // CHECK-NEXT: | [sizeof=48, align=16 131 // CHECK-NEXT: | nvsize=32, nvalign=16] 132 // CHECK-X64: *** Dumping AST Record Layout 133 // CHECK-X64: *** Dumping AST Record Layout 134 // CHECK-X64-NEXT: 0 | struct D 135 // CHECK-X64-NEXT: 0 | struct B4 (primary base) 136 // CHECK-X64-NEXT: 0 | (B4 vftable pointer) 137 // CHECK-X64-NEXT: 8 | (B4 vbtable pointer) 138 // CHECK-X64-NEXT: 16 | struct B0 (base) 139 // CHECK-X64-NEXT: 16 | int a 140 // CHECK-X64-NEXT: 32 | int a 141 // CHECK-X64-NEXT: 48 | struct B1 (virtual base) 142 // CHECK-X64-NEXT: 48 | int a 143 // CHECK-X64-NEXT: | [sizeof=64, align=16 144 // CHECK-X64-NEXT: | nvsize=48, nvalign=16] 145 146 int a[ 147 sizeof(A)+ 148 sizeof(B)+ 149 sizeof(C)+ 150 sizeof(D)]; 151