1 // RUN: %clang_cc1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple i686-pc-windows-msvc -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s --check-prefix=MSVC
3
4 template<typename T> struct Identity {
5 typedef T Type;
6 };
7
f(Identity<int>::Type a)8 void f(Identity<int>::Type a) {}
f(Identity<int> a)9 void f(Identity<int> a) {}
f(int & a)10 void f(int& a) { }
11
12 template<typename T> struct A {
13 A<T> *next;
14 };
f(A<int>)15 void f(A<int>) { }
16
17 struct B { };
18
f()19 void f() {
20 int B::*a = 0;
21 void (B::*b)() = 0;
22 }
23
24 namespace EmptyNameCrash {
25 struct A { A(); };
26 typedef struct { A x; } B;
27 B x;
28 }
29
30 // PR4890
31 namespace PR4890 {
32 struct X {
33 ~X();
34 };
35
~X()36 X::~X() { }
37 }
38
39 namespace VirtualDtor {
40 struct Y {
41 virtual ~Y();
42 };
43
~Y()44 Y::~Y() { }
45 }
46
47 namespace VirtualBase {
48 struct A { int a; };
49 struct B : virtual A { int b; };
50
f()51 void f() {
52 B b;
53 }
54 }
55
56 // CHECK: define void @_ZN7pr147634funcENS_3fooE
57 // CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[F:.*]], metadata ![[EXPR:.*]])
58
59 // MSVC: [[VBASE_B:![0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B",{{.*}} line: 49
60 // MSVC-SAME: size: 96, align: 32
61 // MSVC-NOT: offset:
62 // MSVC-NOT: DIFlagFwdDecl
63 // MSVC-SAME: elements: [[VBASE_B_DEF:![0-9]+]]
64 // MSVC: [[VBASE_B_DEF]] = !{[[VBASE_A_IN_B:![0-9]+]],
65 //
66 // Look for the vbtable offset of A, which should be 4.
67 // MSVC: [[VBASE_A_IN_B]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: [[VBASE_B]],
68 // MSVC-SAME: baseType: !{{[0-9]*}}
69
70 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "B",{{.*}} line: 49,
71 // CHECK-SAME: size: 128, align: 64,
72 // CHECK-NOT: offset:
73 // CHECK-NOT: DIFlagFwdDecl
74 // CHECK-SAME: elements: [[VBASE_B_DEF:![^,)]+]]
75 // CHECK: [[VBASE_B_DEF]] = !{[[VBASE_A_IN_B:![0-9]+]],
76 //
77 // Look for the vtable offset offset, which should be -24.
78 // CHECK: [[VBASE_A_IN_B]] = !DIDerivedType(tag: DW_TAG_inheritance
79 // CHECK-SAME: scope: !"_ZTSN11VirtualBase1BE"
80 // CHECK-SAME: baseType: !"_ZTSN11VirtualBase1AE"
81 // CHECK-SAME: offset: 24,
82 namespace b5249287 {
83 template <typename T> class A {
84 struct B;
85 };
86
87 class Cls {
88 template <typename T> friend class A<T>::B;
89 };
90
91 Cls obj;
92 }
93
94 namespace pr14763 {
95 struct foo {
96 foo(const foo&);
97 };
98
func(foo f)99 foo func(foo f) {
100 return f; // reference 'f' for now because otherwise we hit another bug
101 }
102
103 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
104 // CHECK-SAME: scope: [[PR14763:![0-9]+]]
105 // CHECK-SAME: identifier: "[[FOO:.*]]"
106 // CHECK: [[PR14763]] = !DINamespace(name: "pr14763"
107 // CHECK: [[INCTYPE:![0-9]*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "incomplete"
108 // CHECK-SAME: DIFlagFwdDecl
109 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "a"
110 // CHECK-SAME: elements: [[A_MEM:![0-9]+]]
111 // CHECK-SAME: identifier: "_ZTSN7pr162141aE"
112 // CHECK: [[A_MEM]] = !{[[A_I:![0-9]*]]}
113 // CHECK: [[A_I]] = !DIDerivedType(tag: DW_TAG_member, name: "i"
114 // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "b"
115 // CHECK-SAME: DIFlagFwdDecl
116
117 // CHECK: [[FUNC:![0-9]+]] = distinct !DISubprogram(name: "func", linkageName: "_ZN7pr147634funcENS_3fooE"
118 // CHECK-SAME: type: [[FUNC_TYPE:![0-9]*]]
119 // CHECK-SAME: isDefinition: true
120 }
121
foo()122 void foo() {
123 const wchar_t c = L'x';
124 wchar_t d = c;
125 }
126
127 // CHECK-NOT: !DIGlobalVariable(name: "c"
128
129 namespace pr9608 { // also pr9600
130 struct incomplete;
131 incomplete (*x)[3];
132 // CHECK: !DIGlobalVariable(name: "x", linkageName: "_ZN6pr96081xE"
133 // CHECK-SAME: type: [[INCARRAYPTR:![0-9]*]]
134 // CHECK-SAME: variable: [3 x i8]** @_ZN6pr96081xE
135 // CHECK: [[INCARRAYPTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[INCARRAY:![0-9]+]]
136 // CHECK: [[INCARRAY]] = !DICompositeType(tag: DW_TAG_array_type
137 // CHECK-NOT: line:
138 // CHECK-NOT: size:
139 // CHECK-NOT: align:
140 // CHECK-NOT: offset:
141 // CHECK-SAME: baseType: !"_ZTSN6pr960810incompleteE"
142 }
143
144 // For some reason function arguments ended up down here
145 // CHECK: ![[F]] = !DILocalVariable(name: "f", arg: 1, scope: [[FUNC]]
146 // CHECK-SAME: type: !"[[FOO]]"
147 // CHECK: ![[EXPR]] = !DIExpression(DW_OP_deref)
148
149 // CHECK: !DILocalVariable(name: "c"
150 // CHECK-NOT: arg:
151 // CHECK-SAME: )
152
153 namespace pr16214 {
154 struct a {
155 int i;
156 };
157
158 typedef a at;
159
160 struct b {
161 };
162
163 typedef b bt;
164
func()165 void func() {
166 at a_inst;
167 bt *b_ptr_inst;
168 const bt *b_cnst_ptr_inst;
169 }
170
171 }
172