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