xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/debug-info.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -g %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc template<typename T> struct Identity {
3*f4a2713aSLionel Sambuc   typedef T Type;
4*f4a2713aSLionel Sambuc };
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc void f(Identity<int>::Type a) {}
7*f4a2713aSLionel Sambuc void f(Identity<int> a) {}
8*f4a2713aSLionel Sambuc void f(int& a) { }
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc template<typename T> struct A {
11*f4a2713aSLionel Sambuc   A<T> *next;
12*f4a2713aSLionel Sambuc };
13*f4a2713aSLionel Sambuc void f(A<int>) { }
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc struct B { };
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc void f() {
18*f4a2713aSLionel Sambuc   int B::*a = 0;
19*f4a2713aSLionel Sambuc   void (B::*b)() = 0;
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc namespace EmptyNameCrash {
23*f4a2713aSLionel Sambuc   struct A { A(); };
24*f4a2713aSLionel Sambuc   typedef struct { A x; } B;
25*f4a2713aSLionel Sambuc   B x;
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // PR4890
29*f4a2713aSLionel Sambuc namespace PR4890 {
30*f4a2713aSLionel Sambuc   struct X {
31*f4a2713aSLionel Sambuc     ~X();
32*f4a2713aSLionel Sambuc   };
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc   X::~X() { }
35*f4a2713aSLionel Sambuc }
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc namespace VirtualDtor {
38*f4a2713aSLionel Sambuc   struct Y {
39*f4a2713aSLionel Sambuc     virtual ~Y();
40*f4a2713aSLionel Sambuc   };
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc   Y::~Y() { }
43*f4a2713aSLionel Sambuc }
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc namespace VirtualBase {
46*f4a2713aSLionel Sambuc   struct A { };
47*f4a2713aSLionel Sambuc   struct B : virtual A { };
48*f4a2713aSLionel Sambuc 
49*f4a2713aSLionel Sambuc   void f() {
50*f4a2713aSLionel Sambuc     B b;
51*f4a2713aSLionel Sambuc   }
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc void foo() {
55*f4a2713aSLionel Sambuc   const wchar_t c = L'x';
56*f4a2713aSLionel Sambuc   wchar_t d = c;
57*f4a2713aSLionel Sambuc }
58*f4a2713aSLionel Sambuc 
59*f4a2713aSLionel Sambuc namespace b5249287 {
60*f4a2713aSLionel Sambuc template <typename T> class A {
61*f4a2713aSLionel Sambuc   struct B;
62*f4a2713aSLionel Sambuc };
63*f4a2713aSLionel Sambuc 
64*f4a2713aSLionel Sambuc class Cls {
65*f4a2713aSLionel Sambuc   template <typename T> friend class A<T>::B;
66*f4a2713aSLionel Sambuc };
67*f4a2713aSLionel Sambuc 
68*f4a2713aSLionel Sambuc Cls obj;
69*f4a2713aSLionel Sambuc }
70*f4a2713aSLionel Sambuc 
71*f4a2713aSLionel Sambuc namespace pr14763 {
72*f4a2713aSLionel Sambuc struct foo {
73*f4a2713aSLionel Sambuc   foo(const foo&);
74*f4a2713aSLionel Sambuc };
75*f4a2713aSLionel Sambuc 
76*f4a2713aSLionel Sambuc foo func(foo f) {
77*f4a2713aSLionel Sambuc   return f; // reference 'f' for now because otherwise we hit another bug
78*f4a2713aSLionel Sambuc }
79*f4a2713aSLionel Sambuc 
80*f4a2713aSLionel Sambuc // CHECK: [[FOO:![0-9]*]] = metadata !{i32 {{[0-9]*}}, metadata !{{[0-9]*}}, metadata [[PR14763:![0-9]*]], {{.*}} ; [ DW_TAG_structure_type ] [foo]
81*f4a2713aSLionel Sambuc // CHECK: [[PR14763]] = {{.*}} ; [ DW_TAG_namespace ] [pr14763]
82*f4a2713aSLionel Sambuc // CHECK: [[INCTYPE:![0-9]*]] = {{.*}} ; [ DW_TAG_structure_type ] [incomplete]{{.*}} [decl]
83*f4a2713aSLionel Sambuc // CHECK: metadata [[A_MEM:![0-9]*]], i32 0, null, null, metadata !"_ZTSN7pr162141aE"} ; [ DW_TAG_structure_type ] [a]
84*f4a2713aSLionel Sambuc // CHECK: [[A_MEM]] = metadata !{metadata [[A_I:![0-9]*]]}
85*f4a2713aSLionel Sambuc // CHECK: [[A_I]] = {{.*}} ; [ DW_TAG_member ] [i] {{.*}} [from int]
86*f4a2713aSLionel Sambuc // CHECK: ; [ DW_TAG_structure_type ] [b] {{.*}}[decl]
87*f4a2713aSLionel Sambuc 
88*f4a2713aSLionel Sambuc // CHECK: [[FUNC:![0-9]*]] = {{.*}} metadata !"_ZN7pr147634funcENS_3fooE", i32 {{[0-9]*}}, metadata [[FUNC_TYPE:![0-9]*]], {{.*}} ; [ DW_TAG_subprogram ] {{.*}} [def] [func]
89*f4a2713aSLionel Sambuc }
90*f4a2713aSLionel Sambuc 
91*f4a2713aSLionel Sambuc namespace pr9608 { // also pr9600
92*f4a2713aSLionel Sambuc struct incomplete;
93*f4a2713aSLionel Sambuc incomplete (*x)[3];
94*f4a2713aSLionel Sambuc // CHECK: metadata [[INCARRAYPTR:![0-9]*]], i32 0, i32 1, [3 x i8]** @_ZN6pr96081xE, null} ; [ DW_TAG_variable ] [x]
95*f4a2713aSLionel Sambuc // CHECK: [[INCARRAYPTR]] = {{.*}}metadata [[INCARRAY:![0-9]*]]} ; [ DW_TAG_pointer_type ]
96*f4a2713aSLionel Sambuc // CHECK: [[INCARRAY]] = {{.*}}metadata !"_ZTSN6pr960810incompleteE", metadata {{![0-9]*}}, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 0, offset 0] [from _ZTSN6pr960810incompleteE]
97*f4a2713aSLionel Sambuc }
98*f4a2713aSLionel Sambuc 
99*f4a2713aSLionel Sambuc // For some reason the argument for PR14763 ended up all the way down here
100*f4a2713aSLionel Sambuc // CHECK: = metadata !{i32 {{[0-9]*}}, metadata [[FUNC]], {{.*}}, metadata [[FOO]], i32 8192, i32 0} ; [ DW_TAG_arg_variable ] [f]
101*f4a2713aSLionel Sambuc 
102*f4a2713aSLionel Sambuc namespace pr16214 {
103*f4a2713aSLionel Sambuc struct a {
104*f4a2713aSLionel Sambuc   int i;
105*f4a2713aSLionel Sambuc };
106*f4a2713aSLionel Sambuc 
107*f4a2713aSLionel Sambuc typedef a at;
108*f4a2713aSLionel Sambuc 
109*f4a2713aSLionel Sambuc struct b {
110*f4a2713aSLionel Sambuc };
111*f4a2713aSLionel Sambuc 
112*f4a2713aSLionel Sambuc typedef b bt;
113*f4a2713aSLionel Sambuc 
114*f4a2713aSLionel Sambuc void func() {
115*f4a2713aSLionel Sambuc   at a_inst;
116*f4a2713aSLionel Sambuc   bt *b_ptr_inst;
117*f4a2713aSLionel Sambuc   const bt *b_cnst_ptr_inst;
118*f4a2713aSLionel Sambuc }
119*f4a2713aSLionel Sambuc 
120*f4a2713aSLionel Sambuc }
121