1 // RUN: %clang %target_itanium_abi_host_triple %s -c -o - -gdwarf-4 -Xclang -gsimple-template-names=mangled -Xclang -debug-forward-template-params -std=c++20 \
2 // RUN:   | llvm-dwarfdump --verify -
3 // RUN: %clang %target_itanium_abi_host_triple %s -c -o - -gdwarf-4 -Xclang -gsimple-template-names=mangled -Xclang -debug-forward-template-params -std=c++20 -gmlt -fdebug-info-for-profiling \
4 // RUN:   | llvm-dwarfdump --verify -
5 // RUN: %clang %target_itanium_abi_host_triple %s -c -o - -gdwarf-4 -Xclang -gsimple-template-names=mangled -Xclang -debug-forward-template-params -std=c++20 -fdebug-types-section \
6 // RUN:   | llvm-dwarfdump --verify -
7 // RUN: %clang %target_itanium_abi_host_triple %s -c -o - -gdwarf-5 -Xclang -gsimple-template-names=mangled -Xclang -debug-forward-template-params -std=c++20 -fdebug-types-section \
8 // RUN:   | llvm-dwarfdump --verify -
9 
10 #include <cstdint>
11 #include <cstddef>
12 template<typename ...Ts>
13 struct t1 {
14 };
15 template<typename ...Ts>
16 struct t2;
17 struct udt {
18 };
19 namespace ns {
20 struct udt {
21 };
22 namespace inner {
23 template<typename T> struct ttp { };
24 struct udt { };
25 }
26 template<template<typename> class T>
ttp_user()27 void ttp_user() { }
28 enum Enumeration { Enumerator1, Enumerator2, Enumerator3 = 1 };
29 enum class EnumerationClass { Enumerator1, Enumerator2, Enumerator3 = 1 };
30 enum { AnonEnum1, AnonEnum2, AnonEnum3 = 1 };
31 enum EnumerationSmall : unsigned char { kNeg = 0xff };
32 }
33 template <typename... Ts>
f1()34 void f1() {
35   t1<Ts...> v1;
36   t2<Ts...> *v2;
37 }
38 template<bool b, int i>
f2()39 void f2() {
40 }
41 template<typename T, T ...A>
f3()42 void f3() {
43 }
44 template<typename T, unsigned = 3>
f4()45 void f4() {
46 }
47 template<typename T, bool b = false>
48 struct t3 { };
49 extern template class t3<int>;
50 template class t3<int>;
51 struct outer_class {
52   struct inner_class {
53   };
54 };
55 int i = 3;
56 template<unsigned N>
57 struct t4 { };
58 namespace {
59 struct t5 { };
60 enum LocalEnum { LocalEnum1 };
61 }
62 template<typename ...T1, typename T2 = int>
f5()63 void f5() { }
64 template<typename T1, typename ...T2>
f6()65 void f6() { }
66 struct t6 {
67   template<typename T>
operator <<t668   void operator<<(int) {
69   }
70   template<typename T>
operator <t671   void operator<(int) {
72   }
73   template<typename T>
operator <=t674   void operator<=(int) {
75   }
76   template<typename T = int>
operator t1<float>*t677   operator t1<float>*() {
78     return nullptr;
79   }
80   template<typename T>
operator -t681   void operator-(int) {
82   }
83   template<typename T>
operator *t684   void operator*(int) {
85   }
86   template<typename T>
operator /t687   void operator/(int) {
88   }
89   template<typename T>
operator %t690   void operator%(int) {
91   }
92   template<typename T>
operator ^t693   void operator^(int) {
94   }
95   template<typename T>
operator &t696   void operator&(int) {
97   }
98   template<typename T>
operator |t699   void operator|(int) {
100   }
101   template<typename T>
operator ~t6102   void operator~() {
103   }
104   template<typename T>
operator !t6105   void operator!() {
106   }
107   template<typename T>
operator =t6108   void operator=(int) {
109   }
110   template<typename T>
operator >t6111   void operator>(int) {
112   }
113   template<typename T>
operator ,t6114   void operator,(int) {
115   }
116   template<typename T>
operator ()t6117   void operator()() {
118   }
119   template<typename T>
operator []t6120   void operator[](int) {
121   }
122   template<typename T>
operator <=>t6123   void operator<=>(int) {
124   }
125   template<typename T>
operator newt6126   void* operator new(std::size_t, T) {
127     __builtin_unreachable();
128   }
129   template<typename T>
operator deletet6130   void operator delete(void*, T) {
131   }
132   template<typename T>
operator new[]t6133   void* operator new[](std::size_t, T) {
134     __builtin_unreachable();
135   }
136   template<typename T>
operator delete[]t6137   void operator delete[](void*, T) {
138   }
139   template<typename T>
operator co_awaitt6140   int operator co_await() { __builtin_unreachable(); }
141 
142 };
operator ""_suff(unsigned long long)143 void operator"" _suff(unsigned long long) {}
f7()144 template<template<typename...> class T> void f7() { }
f8()145 template<template<typename...> class T, typename T2> void f8() { }
146 template<typename T>
147 struct t7;
148 using t7i = t7<int>;
149 template<typename T>
150 struct
151 __attribute__((__preferred_name__(t7i)))
152 t7 {
153 };
154 struct t8 {
155   void mem();
156 };
157 namespace ns {
158 inline namespace inl {
159 template<typename T> struct t9 { };
160 }
161 }
162 template<typename T>
f9()163 void (*f9())() {
164   return nullptr;
165 }
166 struct t10 {
167   template<typename T = void>
t10t10168   t10() { }
169 };
170 
171 template<typename T>
operator_not_really()172 void operator_not_really() {
173 }
174 
175 template<typename T, T ...A>
176 struct t11 {
177 };
178 
179 struct t12 {
180   t11<LocalEnum, LocalEnum1> v1;
181 };
182 
183 template<decltype(ns::AnonEnum1)>
f10()184 void f10() {
185 }
186 
main()187 int main() {
188   struct { } A;
189   auto L = []{};
190   f1<int>();
191   f1<float>();
192   f1<bool>();
193   f1<double>();
194   f1<long>();
195   f1<short>();
196   f1<unsigned>();
197   f1<unsigned long long>();
198   f1<long long>();
199   f1<udt>();
200   f1<ns::udt>();
201   f1<ns::udt*>();
202   f1<ns::inner::udt>();
203   f1<t1<int>>();
204   f1<int, float>();
205   f1<int *>();
206   f1<int &>();
207   f1<int &&>();
208   f1<const int>();
209   f1<int[3]>();
210   f1<void>();
211   f1<outer_class::inner_class>();
212   f1<unsigned long>();
213   f2<true, 3>();
214   f3<ns::Enumeration, ns::Enumerator3, (ns::Enumeration)2>();
215   f3<ns::EnumerationClass, ns::EnumerationClass::Enumerator3, (ns::EnumerationClass)2>();
216   f3<ns::EnumerationSmall, ns::kNeg>();
217   f3<decltype(ns::AnonEnum1), ns::AnonEnum3, (decltype(ns::AnonEnum1))2>();
218   f3<LocalEnum, LocalEnum1>();
219   f3<int*, &i>();
220   f3<int*, nullptr>();
221   t4<3> v2;
222   f3<unsigned long, 1>();
223   f3<unsigned long long, 1>();
224   f3<long, 1>();
225   f3<unsigned int, 1>();
226   f3<short, 1>();
227   f3<unsigned char, (char)0>();
228   f3<signed char, (char)0>();
229   f3<unsigned short, 1, 2>();
230   f3<char, 0, 1, 6, 7, 13, 14, 31, 32, 33, (char)127, (char)128>();
231   f3<__int128, ((__int128)9223372036854775807) * 2>();
232   f4<unsigned int>();
233   f1<t3<int>>();
234   f1<t3<t3<int>>>();
235   f1<decltype(L)>();
236   t3<decltype(L)> v1;
237   f1<t3<t3<decltype(L)>>>();
238   f1<int(float)>();
239   f1<void(...)>();
240   f1<void(int, ...)>();
241   f1<const int &>();
242   f1<const int *&>();
243   f1<t5>();
244   f1<decltype(nullptr)>();
245   f1<long*, long*>();
246   f1<long*, udt*>();
247   f1<void *const>();
248   f1<const void *const *>();
249   f1<void()>();
250   f1<void(*)()>();
251   f1<decltype(&L)>();
252   f1<decltype(A)>();
253   f1<decltype(&A)>();
254   f5<t1<int>>();
255   f5<>();
256   f6<t1<int>>();
257   f1<>();
258   f1<const void*, const void*>();
259   f1<t1<int*>*>();
260   f1<int *[]>();
261   t6 v6;
262   v6.operator<< <int>(1);
263   v6.operator< <int>(1);
264   v6.operator<= <int>(1);
265   v6.operator t1<float>*();
266   v6.operator- <int>(3);
267   v6.operator* <int>(3);
268   v6.operator/ <int>(3);
269   v6.operator% <int>(3);
270   v6.operator^ <int>(3);
271   v6.operator& <int>(3);
272   v6.operator| <int>(3);
273   v6.operator~ <int>();
274   v6.operator! <int>();
275   v6.operator= <int>(3);
276   v6.operator> <int>(3);
277   v6.operator, <int>(3);
278   v6.operator() <int>();
279   v6.operator[] <int>(3);
280   v6.operator<=> <int>(3);
281   t6::operator new(0, 0);
282   t6::operator new[](0, 0);
283   t6::operator delete(nullptr, 0);
284   t6::operator delete[](nullptr, 0);
285   v6.operator co_await<int>();
286   42_suff;
287   struct t7 { };
288   f1<t7>();
289   f1<int(&)[3]>();
290   f1<int(*)[3]>();
291   f7<t1>();
292   f8<t1, int>();
293   using namespace ns;
294   ttp_user<inner::ttp>();
295   f1<int*, decltype(nullptr)*>();
296   t7i x;
297   f1<t7i>();
298   f7<ns::inl::t9>();
299   f1<_Atomic(int)>();
300   f1<int, long, volatile char>();
301   f1<__attribute__((__vector_size__(sizeof(int) * 2))) int>();
302   f1<int *const volatile>();
303   f1<const volatile void>();
304   f1<t1<decltype(L)>>();
305   t10 v3;
306   f1<void (::udt::*)() const>();
307   f1<void (::udt::*)() volatile &>();
308   f1<void (::udt::*)() const volatile &&>();
309   f9<int>();
310   f1<void (*const)()>();
311   f1<char const (&)[1]>();
312   f1<void () const &>();
313   f1<void () volatile &&>();
314   f1<void () const volatile>();
315   f1<int *const[1]>();
316   f1<int *const(&)[1]>();
317   f1<void (::udt::* const&)()>();
318   f1<void (*(int))(float)>();
319   f1<t1<int>[1]>();
320   f1<void (*)() noexcept>();
321   f1<void (decltype(A))>();
322   struct t8 { decltype(A) m; };
323   f1<void(t8, decltype(A))>();
324   f1<void(t8)>();
325   operator_not_really<int>();
326   t12 v4;
327   f1<_BitInt(3)>();
328   f1<const unsigned _BitInt(5)>();
329   f1<void(t1<>, t1<>)>();
330   f1<int t1<>::*>();
331   void fcc() __attribute__((swiftcall));
332   f1<decltype(fcc)>();
333   int fnrt() __attribute__((noreturn));
334   f1<decltype(fnrt)>();
335   f10<ns::AnonEnum1>();
336 }
mem()337 void t8::mem() {
338   struct t7 { };
339   f1<t7>();
340   f1<decltype(&t8::mem)>();
341 }
342 namespace complex_type_units {
343 void external_function();
344 namespace {
345 struct internal_type;
346 }
347 template <void (*)() = external_function> struct t2;
348 template <typename = t2<>> class t3 {};
349 template <typename = internal_type, typename = t3<>>
350 struct t4 {
351 };
352 struct t5 {
353     t4<> v1;
354 };
f1()355 void f1() {
356   t5 v1;
357   t3<> v2;
358 }
359 }
360