xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/debug-info-class.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc struct foo;
2*f4a2713aSLionel Sambuc void func(foo *f) {
3*f4a2713aSLionel Sambuc }
4*f4a2713aSLionel Sambuc class bar;
5*f4a2713aSLionel Sambuc void func(bar *f) {
6*f4a2713aSLionel Sambuc }
7*f4a2713aSLionel Sambuc union baz;
8*f4a2713aSLionel Sambuc void func(baz *f) {
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc class B {
12*f4a2713aSLionel Sambuc public:
13*f4a2713aSLionel Sambuc   virtual ~B();
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc B::~B() {
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc struct C {
20*f4a2713aSLionel Sambuc   static int s;
21*f4a2713aSLionel Sambuc   virtual ~C();
22*f4a2713aSLionel Sambuc };
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc C::~C() {
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc struct D {
28*f4a2713aSLionel Sambuc   D();
29*f4a2713aSLionel Sambuc   virtual ~D();
30*f4a2713aSLionel Sambuc   void func() {
31*f4a2713aSLionel Sambuc   }
32*f4a2713aSLionel Sambuc };
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc struct E {
35*f4a2713aSLionel Sambuc   E();
36*f4a2713aSLionel Sambuc   virtual ~E();
37*f4a2713aSLionel Sambuc   virtual void func() {
38*f4a2713aSLionel Sambuc   }
39*f4a2713aSLionel Sambuc };
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc struct F {
42*f4a2713aSLionel Sambuc   struct inner {
43*f4a2713aSLionel Sambuc   };
44*f4a2713aSLionel Sambuc   static const int i = 2;
45*f4a2713aSLionel Sambuc   virtual ~F();
46*f4a2713aSLionel Sambuc };
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc struct G {
49*f4a2713aSLionel Sambuc   virtual void func();
50*f4a2713aSLionel Sambuc   struct inner {
51*f4a2713aSLionel Sambuc     int j;
52*f4a2713aSLionel Sambuc   };
53*f4a2713aSLionel Sambuc };
54*f4a2713aSLionel Sambuc 
55*f4a2713aSLionel Sambuc struct H {};
56*f4a2713aSLionel Sambuc struct I : virtual H {};
57*f4a2713aSLionel Sambuc struct J : I {};
58*f4a2713aSLionel Sambuc J j;
59*f4a2713aSLionel Sambuc 
60*f4a2713aSLionel Sambuc struct A {
61*f4a2713aSLionel Sambuc   int one;
62*f4a2713aSLionel Sambuc   static const int HdrSize = 52;
63*f4a2713aSLionel Sambuc   int two;
64*f4a2713aSLionel Sambuc   A() {
65*f4a2713aSLionel Sambuc     int x = 1;
66*f4a2713aSLionel Sambuc   }
67*f4a2713aSLionel Sambuc };
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc void f1() {
70*f4a2713aSLionel Sambuc   D x;
71*f4a2713aSLionel Sambuc   x.func();
72*f4a2713aSLionel Sambuc   E y;
73*f4a2713aSLionel Sambuc   int i = F::i;
74*f4a2713aSLionel Sambuc   F::inner z;
75*f4a2713aSLionel Sambuc }
76*f4a2713aSLionel Sambuc 
77*f4a2713aSLionel Sambuc int main(int argc, char **argv) {
78*f4a2713aSLionel Sambuc   B b;
79*f4a2713aSLionel Sambuc   G::inner c_i;
80*f4a2713aSLionel Sambuc   if (argc) {
81*f4a2713aSLionel Sambuc     A a;
82*f4a2713aSLionel Sambuc   }
83*f4a2713aSLionel Sambuc   return 0;
84*f4a2713aSLionel Sambuc }
85*f4a2713aSLionel Sambuc 
86*f4a2713aSLionel Sambuc // RUN: %clang -target x86_64-unknown_unknown -emit-llvm -g -S %s -o - | FileCheck %s
87*f4a2713aSLionel Sambuc // RUN: %clang -target i686-cygwin -emit-llvm -g -S %s -o - | FileCheck %s
88*f4a2713aSLionel Sambuc // RUN: %clang -target armv7l-unknown-linux-gnueabihf -emit-llvm -g -S %s -o - | FileCheck %s
89*f4a2713aSLionel Sambuc 
90*f4a2713aSLionel Sambuc // CHECK: invoke {{.+}} @_ZN1BD1Ev(%class.B* %b)
91*f4a2713aSLionel Sambuc // CHECK-NEXT: unwind label %{{.+}}, !dbg ![[EXCEPTLOC:.*]]
92*f4a2713aSLionel Sambuc // CHECK: store i32 0, i32* %{{.+}}, !dbg ![[RETLOC:.*]]
93*f4a2713aSLionel Sambuc // CHECK: DW_TAG_structure_type ] [foo]
94*f4a2713aSLionel Sambuc // CHECK: DW_TAG_class_type ] [bar]
95*f4a2713aSLionel Sambuc // CHECK: DW_TAG_union_type ] [baz]
96*f4a2713aSLionel Sambuc // CHECK: DW_TAG_class_type ] [B] {{.*}} [def]
97*f4a2713aSLionel Sambuc // CHECK: metadata !"_vptr$B", {{.*}}, i32 64, metadata !{{.*}}} ; [ DW_TAG_member ]
98*f4a2713aSLionel Sambuc 
99*f4a2713aSLionel Sambuc // CHECK: [[C:![0-9]*]] = {{.*}} metadata [[C_MEM:![0-9]*]], i32 0, metadata !"_ZTS1C", null, metadata !"_ZTS1C"} ; [ DW_TAG_structure_type ] [C] {{.*}} [def]
100*f4a2713aSLionel Sambuc // CHECK: [[C_MEM]] = metadata !{metadata [[C_VPTR:![0-9]*]], metadata [[C_S:![0-9]*]], metadata [[C_DTOR:![0-9]*]]}
101*f4a2713aSLionel Sambuc // CHECK: [[C_VPTR]] = {{.*}} ; [ DW_TAG_member ] [_vptr$C] {{.*}} [artificial]
102*f4a2713aSLionel Sambuc // CHECK: [[C_S]] = {{.*}} ; [ DW_TAG_member ] [s] {{.*}} [static] [from int]
103*f4a2713aSLionel Sambuc // CHECK: [[C_DTOR]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [~C]
104*f4a2713aSLionel Sambuc 
105*f4a2713aSLionel Sambuc // CHECK: metadata [[D_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS1D"} ; [ DW_TAG_structure_type ] [D] {{.*}} [decl]
106*f4a2713aSLionel Sambuc // CHECK: [[D_MEM]] = metadata !{metadata [[D_FUNC:![0-9]*]]}
107*f4a2713aSLionel Sambuc // CHECK: [[D_FUNC]] = {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [func]
108*f4a2713aSLionel Sambuc // CHECK: null, i32 0, null, null, metadata !"_ZTS1E"} ; [ DW_TAG_structure_type ] [E] {{.*}} [decl]
109*f4a2713aSLionel Sambuc // CHECK: [[F:![0-9]*]] = {{.*}} metadata [[F_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTS1F"} ; [ DW_TAG_structure_type ] [F] {{.*}} [decl]
110*f4a2713aSLionel Sambuc // CHECK: [[F_MEM]] = metadata !{metadata [[F_I:![0-9]*]]}
111*f4a2713aSLionel Sambuc // CHECK: [[F_I]] = {{.*}} ; [ DW_TAG_member ] [i]
112*f4a2713aSLionel Sambuc 
113*f4a2713aSLionel Sambuc // CHECK: null, i32 0, null, null, metadata !"_ZTS1G"} ; [ DW_TAG_structure_type ] [G] {{.*}} [decl]
114*f4a2713aSLionel Sambuc // CHECK: metadata [[G_INNER_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN1G5innerE"} ; [ DW_TAG_structure_type ] [inner] [line 50, {{.*}} [def]
115*f4a2713aSLionel Sambuc // CHECK: [[G_INNER_MEM]] = metadata !{metadata [[G_INNER_I:![0-9]*]]}
116*f4a2713aSLionel Sambuc // CHECK: [[G_INNER_I]] = {{.*}} ; [ DW_TAG_member ] [j] {{.*}} [from int]
117*f4a2713aSLionel Sambuc 
118*f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_structure_type ] [A]
119*f4a2713aSLionel Sambuc // CHECK: HdrSize
120*f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_structure_type ] [I] {{.*}} [def]
121*f4a2713aSLionel Sambuc 
122*f4a2713aSLionel Sambuc // CHECK: [[F_I_DEF:![0-9]*]] = {{.*}}, metadata [[F_I]]} ; [ DW_TAG_variable ] [i]
123*f4a2713aSLionel Sambuc 
124*f4a2713aSLionel Sambuc // CHECK: ![[EXCEPTLOC]] = metadata !{i32 84,
125*f4a2713aSLionel Sambuc // CHECK: ![[RETLOC]] = metadata !{i32 83,
126