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