blob: a5531dadebb3e123f7aabdac2560742bc5c9b915 [file] [log] [blame]
David Blaikie9417b052012-11-02 20:49:01 +00001struct foo;
David Blaikie0a0f93c2013-02-01 19:09:49 +00002void func(foo *f) {
David Blaikie9417b052012-11-02 20:49:01 +00003}
4class bar;
David Blaikie0a0f93c2013-02-01 19:09:49 +00005void func(bar *f) {
David Blaikie9417b052012-11-02 20:49:01 +00006}
7union baz;
David Blaikie0a0f93c2013-02-01 19:09:49 +00008void func(baz *f) {
David Blaikie9417b052012-11-02 20:49:01 +00009}
NAKAMURA Takumi95f36362013-02-03 12:52:54 +000010
David Blaikie0a0f93c2013-02-01 19:09:49 +000011class B {
David Blaikiec9a91772012-12-13 22:29:06 +000012public:
13 virtual ~B();
David Blaikiec9a91772012-12-13 22:29:06 +000014};
David Blaikie498298d2013-08-18 16:55:33 +000015
David Blaikie5434fc22013-08-20 01:28:15 +000016B::~B() {
17}
18
David Blaikie498298d2013-08-18 16:55:33 +000019struct C {
David Blaikie5434fc22013-08-20 01:28:15 +000020 static int s;
21 virtual ~C();
22};
23
24C::~C() {
25}
26
27struct D {
28 D();
29 virtual ~D();
30 void func() {
31 }
32};
33
34struct E {
35 E();
36 virtual ~E();
37 virtual void func() {
38 }
39};
40
41struct F {
42 struct inner {
43 };
44 static const int i = 2;
45 virtual ~F();
46};
47
48struct G {
David Blaikie498298d2013-08-18 16:55:33 +000049 virtual void func();
50 struct inner {
51 int j;
52 };
53};
54
David Blaikie6a29f672013-08-22 15:23:05 +000055struct H {};
56struct I : virtual H {};
57struct J : I {};
58J j;
59
David Blaikie0a0f93c2013-02-01 19:09:49 +000060struct A {
Devang Pateldabc3e92010-08-12 00:02:44 +000061 int one;
David Blaikie0a0f93c2013-02-01 19:09:49 +000062 static const int HdrSize = 52;
Devang Pateldabc3e92010-08-12 00:02:44 +000063 int two;
64 A() {
65 int x = 1;
66 }
67};
David Blaikiec9a91772012-12-13 22:29:06 +000068
David Blaikie5434fc22013-08-20 01:28:15 +000069void f1() {
70 D x;
71 x.func();
72 E y;
73 int i = F::i;
74 F::inner z;
75}
David Blaikiec9a91772012-12-13 22:29:06 +000076
David Blaikie0a0f93c2013-02-01 19:09:49 +000077int main(int argc, char **argv) {
David Blaikie9417b052012-11-02 20:49:01 +000078 B b;
David Blaikie5434fc22013-08-20 01:28:15 +000079 G::inner c_i;
David Blaikie0a0f93c2013-02-01 19:09:49 +000080 if (argc) {
81 A a;
82 }
83 return 0;
Devang Pateldabc3e92010-08-12 00:02:44 +000084}
David Blaikie0a0f93c2013-02-01 19:09:49 +000085
NAKAMURA Takumi95f36362013-02-03 12:52:54 +000086// RUN: %clang -target x86_64-unknown_unknown -emit-llvm -g -S %s -o - | FileCheck %s
87// RUN: %clang -target i686-cygwin -emit-llvm -g -S %s -o - | FileCheck %s
88// RUN: %clang -target armv7l-unknown-linux-gnueabihf -emit-llvm -g -S %s -o - | FileCheck %s
89
90// CHECK: invoke {{.+}} @_ZN1BD1Ev(%class.B* %b)
NAKAMURA Takumi288c7552013-02-01 22:53:19 +000091// CHECK-NEXT: unwind label %{{.+}}, !dbg ![[EXCEPTLOC:.*]]
92// CHECK: store i32 0, i32* %{{.+}}, !dbg ![[RETLOC:.*]]
David Blaikie0a0f93c2013-02-01 19:09:49 +000093// CHECK: DW_TAG_structure_type ] [foo]
94// CHECK: DW_TAG_class_type ] [bar]
95// CHECK: DW_TAG_union_type ] [baz]
David Blaikie0a0f93c2013-02-01 19:09:49 +000096// CHECK: DW_TAG_class_type ] [B]
97// CHECK: metadata !"_vptr$B", {{.*}}, i32 64, metadata !{{.*}}} ; [ DW_TAG_member ]
David Blaikie5434fc22013-08-20 01:28:15 +000098
Manman Renf1acc312013-08-29 18:51:51 +000099// CHECK: [[C:![0-9]*]] = {{.*}} metadata [[C_MEM:![0-9]*]], i32 0, metadata [[C]], null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] {{.*}} [def]
David Blaikie5434fc22013-08-20 01:28:15 +0000100// CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_S:![0-9]*]], metadata [[C_DTOR:![0-9]*]]}
101// CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$C] {{.*}} [artificial]
102// CHECK: [[C_S]] = {{.*}} ; [ DW_TAG_member ] [s] {{.*}} [static] [from int]
103// CHECK: [[C_DTOR]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [~C]
104
Manman Renf1acc312013-08-29 18:51:51 +0000105// CHECK: ; [ DW_TAG_structure_type ] [I] {{.*}} [def]
106// CHECK: metadata [[D_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS1D"} ; [ DW_TAG_structure_type ] [D] {{.*}} [decl]
David Blaikie5434fc22013-08-20 01:28:15 +0000107// CHECK: [[D_MEM]] = metadata !{metadata [[D_FUNC:![0-9]*]]}
108// CHECK: [[D_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
Manman Renf1acc312013-08-29 18:51:51 +0000109// CHECK: null, i32 0, null, null, metadata !"_ZTS1E"} ; [ DW_TAG_structure_type ] [E] {{.*}} [decl]
110// CHECK: [[F:![0-9]*]] = {{.*}} metadata [[F_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS1F"} ; [ DW_TAG_structure_type ] [F] {{.*}} [def]
111// CHECK: [[F_MEM]] = metadata !{metadata [[F_I:![0-9]*]]}
David Blaikie5434fc22013-08-20 01:28:15 +0000112// CHECK: [[F_I]] = {{.*}} ; [ DW_TAG_member ] [i]
David Blaikie5434fc22013-08-20 01:28:15 +0000113
David Blaikie498298d2013-08-18 16:55:33 +0000114// Context chains (in Clang -flimit-debug-info and in GCC generally) contain
115// definitions without members (& without a vbase 'containing type'):
Manman Renf1acc312013-08-29 18:51:51 +0000116// CHECK: null, i32 0, null, null, metadata !"_ZTS1G"} ; [ DW_TAG_structure_type ] [G] {{.*}} [def]
117// CHECK: metadata [[G_INNER_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN1G5innerE"} ; [ DW_TAG_structure_type ] [inner] [line 50, {{.*}} [def]
David Blaikie5434fc22013-08-20 01:28:15 +0000118// CHECK: [[G_INNER_MEM]] = metadata !{metadata [[G_INNER_I:![0-9]*]]}
119// CHECK: [[G_INNER_I]] = {{.*}} ; [ DW_TAG_member ] [j] {{.*}} [from int]
120
Manman Renf1acc312013-08-29 18:51:51 +0000121// CHECK: ; [ DW_TAG_structure_type ] [A]
122// CHECK: HdrSize
123
124// CHECK: [[F_I_DEF:![0-9]*]] = {{.*}}, metadata [[F_I]]} ; [ DW_TAG_variable ] [i]
125
David Blaikie6a29f672013-08-22 15:23:05 +0000126// CHECK: ![[EXCEPTLOC]] = metadata !{i32 84,
127// CHECK: ![[RETLOC]] = metadata !{i32 83,