xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/mangle-ms.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=i386-pc-win32 -std=c++98 | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -triple=x86_64-pc-win32 -std=c++98| FileCheck -check-prefix X64 %s
3f4a2713aSLionel Sambuc 
4f4a2713aSLionel Sambuc int a;
5f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?a@@3HA"
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc namespace N {
8f4a2713aSLionel Sambuc   int b;
9f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?b@N@@3HA"
10f4a2713aSLionel Sambuc 
11f4a2713aSLionel Sambuc   namespace {
12f4a2713aSLionel Sambuc     int anonymous;
13f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?anonymous@?A@N@@3HA"
14f4a2713aSLionel Sambuc   }
15f4a2713aSLionel Sambuc }
16f4a2713aSLionel Sambuc 
17f4a2713aSLionel Sambuc static int c;
18f4a2713aSLionel Sambuc // CHECK-DAG: @c
19f4a2713aSLionel Sambuc 
_c(void)20f4a2713aSLionel Sambuc int _c(void) {return N::anonymous + c;}
21f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?_c@@YAHXZ"
22f4a2713aSLionel Sambuc // X64-DAG:   @"\01?_c@@YAHXZ"
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc class foo {
25f4a2713aSLionel Sambuc   static const short d;
26f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?d@foo@@0FB"
27f4a2713aSLionel Sambuc protected:
28f4a2713aSLionel Sambuc   static volatile long e;
29f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?e@foo@@1JC"
30f4a2713aSLionel Sambuc public:
31f4a2713aSLionel Sambuc   static const volatile char f;
32f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?f@foo@@2DD"
33f4a2713aSLionel Sambuc   int operator+(int a);
foo()34f4a2713aSLionel Sambuc   foo(){}
35f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??0foo@@QAE@XZ"
36f4a2713aSLionel Sambuc // X64-DAG:   @"\01??0foo@@QEAA@XZ"
37f4a2713aSLionel Sambuc 
~foo()38f4a2713aSLionel Sambuc   ~foo(){}
39f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??1foo@@QAE@XZ"
40f4a2713aSLionel Sambuc // X64-DAG:   @"\01??1foo@@QEAA@XZ
41f4a2713aSLionel Sambuc 
foo(int i)42f4a2713aSLionel Sambuc   foo(int i){}
43f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??0foo@@QAE@H@Z"
44f4a2713aSLionel Sambuc // X64-DAG:   @"\01??0foo@@QEAA@H@Z"
45f4a2713aSLionel Sambuc 
foo(char * q)46f4a2713aSLionel Sambuc   foo(char *q){}
47f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??0foo@@QAE@PAD@Z"
48f4a2713aSLionel Sambuc // X64-DAG:   @"\01??0foo@@QEAA@PEAD@Z"
49f4a2713aSLionel Sambuc 
static_method()50f4a2713aSLionel Sambuc   static foo* static_method() { return 0; }
51f4a2713aSLionel Sambuc 
52f4a2713aSLionel Sambuc }f,s1(1),s2((char*)0);
53f4a2713aSLionel Sambuc 
54f4a2713aSLionel Sambuc typedef foo (foo2);
55f4a2713aSLionel Sambuc 
56f4a2713aSLionel Sambuc struct bar {
57f4a2713aSLionel Sambuc   static int g;
58f4a2713aSLionel Sambuc };
59f4a2713aSLionel Sambuc 
60f4a2713aSLionel Sambuc union baz {
61f4a2713aSLionel Sambuc   int a;
62f4a2713aSLionel Sambuc   char b;
63f4a2713aSLionel Sambuc   double c;
64f4a2713aSLionel Sambuc };
65f4a2713aSLionel Sambuc 
66f4a2713aSLionel Sambuc enum quux {
67f4a2713aSLionel Sambuc   qone,
68f4a2713aSLionel Sambuc   qtwo,
69f4a2713aSLionel Sambuc   qthree
70f4a2713aSLionel Sambuc };
71f4a2713aSLionel Sambuc 
bar()72f4a2713aSLionel Sambuc foo bar() { return foo(); }
73f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?bar@@YA?AVfoo@@XZ"
74f4a2713aSLionel Sambuc // X64-DAG:   @"\01?bar@@YA?AVfoo@@XZ"
75f4a2713aSLionel Sambuc 
operator +(int a)76f4a2713aSLionel Sambuc int foo::operator+(int a) {
77f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??Hfoo@@QAEHH@Z"
78f4a2713aSLionel Sambuc // X64-DAG:   @"\01??Hfoo@@QEAAHH@Z"
79f4a2713aSLionel Sambuc 
80f4a2713aSLionel Sambuc   foo::static_method();
81f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?static_method@foo@@SAPAV1@XZ"
82f4a2713aSLionel Sambuc // X64-DAG:   @"\01?static_method@foo@@SAPEAV1@XZ"
83f4a2713aSLionel Sambuc   bar();
84f4a2713aSLionel Sambuc   return a;
85f4a2713aSLionel Sambuc }
86f4a2713aSLionel Sambuc 
87f4a2713aSLionel Sambuc const short foo::d = 0;
88f4a2713aSLionel Sambuc volatile long foo::e;
89f4a2713aSLionel Sambuc const volatile char foo::f = 'C';
90f4a2713aSLionel Sambuc 
91f4a2713aSLionel Sambuc int bar::g;
92f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?g@bar@@2HA"
93f4a2713aSLionel Sambuc 
94f4a2713aSLionel Sambuc extern int * const h1 = &a;
95f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?h1@@3QAHA"
96f4a2713aSLionel Sambuc extern const int * const h2 = &a;
97f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?h2@@3QBHB"
98*0a6a1f1dSLionel Sambuc extern int * const __restrict h3 = &a;
99*0a6a1f1dSLionel Sambuc // CHECK-DAG: @"\01?h3@@3QIAHIA"
100*0a6a1f1dSLionel Sambuc // X64-DAG: @"\01?h3@@3QEIAHEIA"
101f4a2713aSLionel Sambuc 
102f4a2713aSLionel Sambuc int i[10][20];
103f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?i@@3PAY0BE@HA"
104f4a2713aSLionel Sambuc 
105*0a6a1f1dSLionel Sambuc typedef int (*FunT)(int, int);
106*0a6a1f1dSLionel Sambuc FunT FunArr[10][20];
107*0a6a1f1dSLionel Sambuc // CHECK-DAG: @"\01?FunArr@@3PAY0BE@P6AHHH@ZA"
108*0a6a1f1dSLionel Sambuc // X64-DAG: @"\01?FunArr@@3PAY0BE@P6AHHH@ZA"
109*0a6a1f1dSLionel Sambuc 
110f4a2713aSLionel Sambuc int (__stdcall *j)(signed char, unsigned char);
111f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?j@@3P6GHCE@ZA"
112f4a2713aSLionel Sambuc 
113f4a2713aSLionel Sambuc const volatile char foo2::*k;
114f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?k@@3PTfoo@@DT1@"
115f4a2713aSLionel Sambuc // X64-DAG:   @"\01?k@@3PETfoo@@DET1@"
116f4a2713aSLionel Sambuc 
117f4a2713aSLionel Sambuc int (foo2::*l)(int);
118f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?l@@3P8foo@@AEHH@ZQ1@"
119f4a2713aSLionel Sambuc 
120*0a6a1f1dSLionel Sambuc // Ensure typedef CV qualifiers are mangled correctly
121*0a6a1f1dSLionel Sambuc typedef const int cInt;
122*0a6a1f1dSLionel Sambuc typedef volatile int vInt;
123*0a6a1f1dSLionel Sambuc typedef const volatile int cvInt;
124*0a6a1f1dSLionel Sambuc 
125*0a6a1f1dSLionel Sambuc extern cInt g_cInt = 1;
126*0a6a1f1dSLionel Sambuc vInt g_vInt = 2;
127*0a6a1f1dSLionel Sambuc cvInt g_cvInt = 3;
128*0a6a1f1dSLionel Sambuc 
129*0a6a1f1dSLionel Sambuc // CHECK-DAG: @"\01?g_cInt@@3HB"
130*0a6a1f1dSLionel Sambuc // CHECK-DAG: @"\01?g_vInt@@3HC"
131*0a6a1f1dSLionel Sambuc // CHECK-DAG: @"\01?g_cvInt@@3HD"
132*0a6a1f1dSLionel Sambuc 
133f4a2713aSLionel Sambuc // Static functions are mangled, too.
134f4a2713aSLionel Sambuc // Also make sure calling conventions, arglists, and throw specs work.
alpha(float a,double b)135f4a2713aSLionel Sambuc static void __stdcall alpha(float a, double b) throw() {}
beta(long long a,wchar_t b)136f4a2713aSLionel Sambuc bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
137f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?beta@@YI_N_J_W@Z"
138f4a2713aSLionel Sambuc // X64-DAG:   @"\01?beta@@YA_N_J_W@Z"
139f4a2713aSLionel Sambuc   alpha(0.f, 0.0);
140f4a2713aSLionel Sambuc   return false;
141f4a2713aSLionel Sambuc }
142f4a2713aSLionel Sambuc 
143f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?alpha@@YGXMN@Z"
144f4a2713aSLionel Sambuc // X64-DAG:   @"\01?alpha@@YAXMN@Z"
145f4a2713aSLionel Sambuc 
146f4a2713aSLionel Sambuc // Make sure tag-type mangling works.
gamma(class foo,struct bar,union baz,enum quux)147f4a2713aSLionel Sambuc void gamma(class foo, struct bar, union baz, enum quux) {}
148f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
149f4a2713aSLionel Sambuc // X64-DAG:   @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
150f4a2713aSLionel Sambuc 
151f4a2713aSLionel Sambuc // Make sure pointer/reference-type mangling works.
delta(int * const a,const long &)152f4a2713aSLionel Sambuc void delta(int * const a, const long &) {}
153f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?delta@@YAXQAHABJ@Z"
154f4a2713aSLionel Sambuc // X64-DAG:   @"\01?delta@@YAXQEAHAEBJ@Z"
155f4a2713aSLionel Sambuc 
156f4a2713aSLionel Sambuc // Array mangling.
epsilon(int a[][10][20])157f4a2713aSLionel Sambuc void epsilon(int a[][10][20]) {}
158f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?epsilon@@YAXQAY19BE@H@Z"
159f4a2713aSLionel Sambuc // X64-DAG:   @"\01?epsilon@@YAXQEAY19BE@H@Z"
160f4a2713aSLionel Sambuc 
zeta(int (*)(int,int))161f4a2713aSLionel Sambuc void zeta(int (*)(int, int)) {}
162f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?zeta@@YAXP6AHHH@Z@Z"
163f4a2713aSLionel Sambuc // X64-DAG:   @"\01?zeta@@YAXP6AHHH@Z@Z"
164f4a2713aSLionel Sambuc 
165f4a2713aSLionel Sambuc // Blocks mangling (Clang extension). A block should be mangled slightly
166f4a2713aSLionel Sambuc // differently from a similar function pointer.
167f4a2713aSLionel Sambuc void eta(int (^)(int, int)) {}
168f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?eta@@YAXP_EAHHH@Z@Z"
169f4a2713aSLionel Sambuc 
170f4a2713aSLionel Sambuc typedef int theta_arg(int,int);
171f4a2713aSLionel Sambuc void theta(theta_arg^ block) {}
172f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?theta@@YAXP_EAHHH@Z@Z"
173f4a2713aSLionel Sambuc 
operator_new_delete()174f4a2713aSLionel Sambuc void operator_new_delete() {
175f4a2713aSLionel Sambuc   char *ptr = new char;
176f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??2@YAPAXI@Z"
177f4a2713aSLionel Sambuc 
178f4a2713aSLionel Sambuc   delete ptr;
179f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??3@YAXPAX@Z"
180f4a2713aSLionel Sambuc 
181f4a2713aSLionel Sambuc   char *array = new char[42];
182f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??_U@YAPAXI@Z"
183f4a2713aSLionel Sambuc 
184f4a2713aSLionel Sambuc   delete [] array;
185f4a2713aSLionel Sambuc // CHECK-DAG: @"\01??_V@YAXPAX@Z"
186f4a2713aSLionel Sambuc }
187f4a2713aSLionel Sambuc 
188f4a2713aSLionel Sambuc // PR13022
189f4a2713aSLionel Sambuc void (redundant_parens)();
redundant_parens_use()190f4a2713aSLionel Sambuc void redundant_parens_use() { redundant_parens(); }
191f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?redundant_parens@@YAXXZ"
192f4a2713aSLionel Sambuc // X64-DAG:   @"\01?redundant_parens@@YAXXZ"
193f4a2713aSLionel Sambuc 
194f4a2713aSLionel Sambuc // PR13047
195f4a2713aSLionel Sambuc typedef double RGB[3];
196f4a2713aSLionel Sambuc RGB color1;
197f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color1@@3PANA"
198f4a2713aSLionel Sambuc extern const RGB color2 = {};
199f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color2@@3QBNB"
200f4a2713aSLionel Sambuc extern RGB const color3[5] = {};
201f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color3@@3QAY02$$CBNA"
202f4a2713aSLionel Sambuc extern RGB const ((color4)[5]) = {};
203f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?color4@@3QAY02$$CBNA"
204f4a2713aSLionel Sambuc 
205f4a2713aSLionel Sambuc struct B;
206f4a2713aSLionel Sambuc volatile int B::* volatile memptr1;
207f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptr1@@3RESB@@HES1@"
208f4a2713aSLionel Sambuc volatile int B::* memptr2;
209f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptr2@@3PESB@@HES1@"
210f4a2713aSLionel Sambuc int B::* volatile memptr3;
211f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptr3@@3REQB@@HEQ1@"
212f4a2713aSLionel Sambuc typedef int (*fun)();
213f4a2713aSLionel Sambuc volatile fun B::* volatile funmemptr1;
214f4a2713aSLionel Sambuc // X64-DAG: @"\01?funmemptr1@@3RESB@@R6AHXZES1@"
215f4a2713aSLionel Sambuc volatile fun B::* funmemptr2;
216f4a2713aSLionel Sambuc // X64-DAG: @"\01?funmemptr2@@3PESB@@R6AHXZES1@"
217f4a2713aSLionel Sambuc fun B::* volatile funmemptr3;
218f4a2713aSLionel Sambuc // X64-DAG: @"\01?funmemptr3@@3REQB@@P6AHXZEQ1@"
219f4a2713aSLionel Sambuc void (B::* volatile memptrtofun1)();
220f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun1@@3R8B@@EAAXXZEQ1@"
221f4a2713aSLionel Sambuc const void (B::* memptrtofun2)();
222f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun2@@3P8B@@EAAXXZEQ1@"
223f4a2713aSLionel Sambuc volatile void (B::* memptrtofun3)();
224f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun3@@3P8B@@EAAXXZEQ1@"
225f4a2713aSLionel Sambuc int (B::* volatile memptrtofun4)();
226f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun4@@3R8B@@EAAHXZEQ1@"
227f4a2713aSLionel Sambuc volatile int (B::* memptrtofun5)();
228f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun5@@3P8B@@EAA?CHXZEQ1@"
229f4a2713aSLionel Sambuc const int (B::* memptrtofun6)();
230f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun6@@3P8B@@EAA?BHXZEQ1@"
231f4a2713aSLionel Sambuc fun (B::* volatile memptrtofun7)();
232f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun7@@3R8B@@EAAP6AHXZXZEQ1@"
233f4a2713aSLionel Sambuc volatile fun (B::* memptrtofun8)();
234f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun8@@3P8B@@EAAR6AHXZXZEQ1@"
235f4a2713aSLionel Sambuc const fun (B::* memptrtofun9)();
236f4a2713aSLionel Sambuc // X64-DAG: @"\01?memptrtofun9@@3P8B@@EAAQ6AHXZXZEQ1@"
237f4a2713aSLionel Sambuc 
238f4a2713aSLionel Sambuc // PR12603
239f4a2713aSLionel Sambuc enum E {};
240f4a2713aSLionel Sambuc // CHECK-DAG: "\01?fooE@@YA?AW4E@@XZ"
241f4a2713aSLionel Sambuc // X64-DAG:   "\01?fooE@@YA?AW4E@@XZ"
fooE()242f4a2713aSLionel Sambuc E fooE() { return E(); }
243f4a2713aSLionel Sambuc 
244f4a2713aSLionel Sambuc class X {};
245f4a2713aSLionel Sambuc // CHECK-DAG: "\01?fooX@@YA?AVX@@XZ"
246f4a2713aSLionel Sambuc // X64-DAG:   "\01?fooX@@YA?AVX@@XZ"
fooX()247f4a2713aSLionel Sambuc X fooX() { return X(); }
248f4a2713aSLionel Sambuc 
249f4a2713aSLionel Sambuc namespace PR13182 {
250f4a2713aSLionel Sambuc   extern char s0[];
251f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s0@PR13182@@3PADA"
252f4a2713aSLionel Sambuc   extern char s1[42];
253f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s1@PR13182@@3PADA"
254f4a2713aSLionel Sambuc   extern const char s2[];
255f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s2@PR13182@@3QBDB"
256f4a2713aSLionel Sambuc   extern const char s3[42];
257f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s3@PR13182@@3QBDB"
258f4a2713aSLionel Sambuc   extern volatile char s4[];
259f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s4@PR13182@@3RCDC"
260f4a2713aSLionel Sambuc   extern const volatile char s5[];
261f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s5@PR13182@@3SDDD"
262f4a2713aSLionel Sambuc   extern const char* const* s6;
263f4a2713aSLionel Sambuc   // CHECK-DAG: @"\01?s6@PR13182@@3PBQBDB"
264f4a2713aSLionel Sambuc 
foo()265f4a2713aSLionel Sambuc   char foo() {
266f4a2713aSLionel Sambuc     return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
267f4a2713aSLionel Sambuc   }
268f4a2713aSLionel Sambuc }
269f4a2713aSLionel Sambuc 
extern_c_func()270f4a2713aSLionel Sambuc extern "C" inline void extern_c_func() {
271f4a2713aSLionel Sambuc   static int local;
272f4a2713aSLionel Sambuc // CHECK-DAG: @"\01?local@?1??extern_c_func@@9@4HA"
273f4a2713aSLionel Sambuc // X64-DAG:   @"\01?local@?1??extern_c_func@@9@4HA"
274f4a2713aSLionel Sambuc }
275f4a2713aSLionel Sambuc 
call_extern_c_func()276f4a2713aSLionel Sambuc void call_extern_c_func() {
277f4a2713aSLionel Sambuc   extern_c_func();
278f4a2713aSLionel Sambuc }
279f4a2713aSLionel Sambuc 
main()280f4a2713aSLionel Sambuc int main() { return 0; }
281f4a2713aSLionel Sambuc // CHECK-DAG: @main
282f4a2713aSLionel Sambuc // X64-DAG:   @main
283f4a2713aSLionel Sambuc 
wmain()284f4a2713aSLionel Sambuc int wmain() { return 0; }
285f4a2713aSLionel Sambuc // CHECK-DAG: @wmain
286f4a2713aSLionel Sambuc // X64-DAG:   @wmain
287f4a2713aSLionel Sambuc 
WinMain()288f4a2713aSLionel Sambuc int WinMain() { return 0; }
289f4a2713aSLionel Sambuc // CHECK-DAG: @WinMain
290f4a2713aSLionel Sambuc // X64-DAG:   @WinMain
291f4a2713aSLionel Sambuc 
wWinMain()292f4a2713aSLionel Sambuc int wWinMain() { return 0; }
293f4a2713aSLionel Sambuc // CHECK-DAG: @wWinMain
294f4a2713aSLionel Sambuc // X64-DAG:   @wWinMain
295f4a2713aSLionel Sambuc 
DllMain()296f4a2713aSLionel Sambuc int DllMain() { return 0; }
297f4a2713aSLionel Sambuc // CHECK-DAG: @DllMain
298f4a2713aSLionel Sambuc // X64-DAG:   @DllMain
299f4a2713aSLionel Sambuc 
inline_function_with_local_type()300f4a2713aSLionel Sambuc inline int inline_function_with_local_type() {
301f4a2713aSLionel Sambuc   static struct {
302f4a2713aSLionel Sambuc     int a_field;
303f4a2713aSLionel Sambuc   } static_variable_in_inline_function = { 20 }, second_static = { 40 };
304f4a2713aSLionel Sambuc   // CHECK: @"\01?static_variable_in_inline_function@?1??inline_function_with_local_type@@YAHXZ@4U<unnamed-type-static_variable_in_inline_function>@?1??1@YAHXZ@A"
305f4a2713aSLionel Sambuc 
306f4a2713aSLionel Sambuc   return static_variable_in_inline_function.a_field + second_static.a_field;
307f4a2713aSLionel Sambuc }
308f4a2713aSLionel Sambuc 
call_inline_function_with_local_type()309f4a2713aSLionel Sambuc int call_inline_function_with_local_type() {
310f4a2713aSLionel Sambuc   return inline_function_with_local_type();
311f4a2713aSLionel Sambuc }
312f4a2713aSLionel Sambuc 
313f4a2713aSLionel Sambuc template <typename T>
templated_inline_function_with_local_type()314f4a2713aSLionel Sambuc inline int templated_inline_function_with_local_type() {
315f4a2713aSLionel Sambuc   static struct {
316f4a2713aSLionel Sambuc     int a_field;
317f4a2713aSLionel Sambuc   } static_variable_in_templated_inline_function = { 20 },
318f4a2713aSLionel Sambuc     second_static = { 40 };
319f4a2713aSLionel Sambuc   // CHECK: @"\01?static_variable_in_templated_inline_function@?1???$templated_inline_function_with_local_type@H@@YAHXZ@4U<unnamed-type-static_variable_in_templated_inline_function>@?1???$templated_inline_function_with_local_type@H@@YAHXZ@A"
320f4a2713aSLionel Sambuc 
321f4a2713aSLionel Sambuc   return static_variable_in_templated_inline_function.a_field +
322f4a2713aSLionel Sambuc          second_static.a_field;
323f4a2713aSLionel Sambuc }
324f4a2713aSLionel Sambuc 
call_templated_inline_function_with_local_type()325f4a2713aSLionel Sambuc int call_templated_inline_function_with_local_type() {
326f4a2713aSLionel Sambuc   return templated_inline_function_with_local_type<int>();
327f4a2713aSLionel Sambuc }
328f4a2713aSLionel Sambuc 
329f4a2713aSLionel Sambuc // PR17371
330f4a2713aSLionel Sambuc struct OverloadedNewDelete {
331f4a2713aSLionel Sambuc   // __cdecl
332f4a2713aSLionel Sambuc   void *operator new(__SIZE_TYPE__);
333f4a2713aSLionel Sambuc   void *operator new[](__SIZE_TYPE__);
334f4a2713aSLionel Sambuc   void operator delete(void *);
335f4a2713aSLionel Sambuc   void operator delete[](void *);
336f4a2713aSLionel Sambuc   // __thiscall
337f4a2713aSLionel Sambuc   int operator+(int);
338f4a2713aSLionel Sambuc };
339f4a2713aSLionel Sambuc 
operator new(__SIZE_TYPE__ s)340f4a2713aSLionel Sambuc void *OverloadedNewDelete::operator new(__SIZE_TYPE__ s) { return 0; }
operator new[](__SIZE_TYPE__ s)341f4a2713aSLionel Sambuc void *OverloadedNewDelete::operator new[](__SIZE_TYPE__ s) { return 0; }
operator delete(void *)342f4a2713aSLionel Sambuc void OverloadedNewDelete::operator delete(void *) { }
operator delete[](void *)343f4a2713aSLionel Sambuc void OverloadedNewDelete::operator delete[](void *) { }
operator +(int x)344f4a2713aSLionel Sambuc int OverloadedNewDelete::operator+(int x) { return x; };
345f4a2713aSLionel Sambuc 
346f4a2713aSLionel Sambuc // CHECK-DAG: ??2OverloadedNewDelete@@SAPAXI@Z
347f4a2713aSLionel Sambuc // CHECK-DAG: ??_UOverloadedNewDelete@@SAPAXI@Z
348f4a2713aSLionel Sambuc // CHECK-DAG: ??3OverloadedNewDelete@@SAXPAX@Z
349f4a2713aSLionel Sambuc // CHECK-DAG: ??_VOverloadedNewDelete@@SAXPAX@Z
350f4a2713aSLionel Sambuc // CHECK-DAG: ??HOverloadedNewDelete@@QAEHH@Z
351f4a2713aSLionel Sambuc 
352f4a2713aSLionel Sambuc // X64-DAG:   ??2OverloadedNewDelete@@SAPEAX_K@Z
353f4a2713aSLionel Sambuc // X64-DAG:   ??_UOverloadedNewDelete@@SAPEAX_K@Z
354f4a2713aSLionel Sambuc // X64-DAG:   ??3OverloadedNewDelete@@SAXPEAX@Z
355f4a2713aSLionel Sambuc // X64-DAG:   ??_VOverloadedNewDelete@@SAXPEAX@Z
356f4a2713aSLionel Sambuc // X64-DAG:   ??HOverloadedNewDelete@@QEAAHH@Z
357f4a2713aSLionel Sambuc 
358f4a2713aSLionel Sambuc // Indirecting the function type through a typedef will require a calling
359f4a2713aSLionel Sambuc // convention adjustment before building the method decl.
360f4a2713aSLionel Sambuc 
361f4a2713aSLionel Sambuc typedef void *__thiscall OperatorNewType(__SIZE_TYPE__);
362f4a2713aSLionel Sambuc typedef void __thiscall OperatorDeleteType(void *);
363f4a2713aSLionel Sambuc 
364f4a2713aSLionel Sambuc struct TypedefNewDelete {
365f4a2713aSLionel Sambuc   OperatorNewType operator new;
366f4a2713aSLionel Sambuc   OperatorNewType operator new[];
367f4a2713aSLionel Sambuc   OperatorDeleteType operator delete;
368f4a2713aSLionel Sambuc   OperatorDeleteType operator delete[];
369f4a2713aSLionel Sambuc };
370f4a2713aSLionel Sambuc 
operator new(__SIZE_TYPE__ s)371f4a2713aSLionel Sambuc void *TypedefNewDelete::operator new(__SIZE_TYPE__ s) { return 0; }
operator new[](__SIZE_TYPE__ s)372f4a2713aSLionel Sambuc void *TypedefNewDelete::operator new[](__SIZE_TYPE__ s) { return 0; }
operator delete(void *)373f4a2713aSLionel Sambuc void TypedefNewDelete::operator delete(void *) { }
operator delete[](void *)374f4a2713aSLionel Sambuc void TypedefNewDelete::operator delete[](void *) { }
375f4a2713aSLionel Sambuc 
376f4a2713aSLionel Sambuc // CHECK-DAG: ??2TypedefNewDelete@@SAPAXI@Z
377f4a2713aSLionel Sambuc // CHECK-DAG: ??_UTypedefNewDelete@@SAPAXI@Z
378f4a2713aSLionel Sambuc // CHECK-DAG: ??3TypedefNewDelete@@SAXPAX@Z
379f4a2713aSLionel Sambuc // CHECK-DAG: ??_VTypedefNewDelete@@SAXPAX@Z
380f4a2713aSLionel Sambuc 
vector_func()381*0a6a1f1dSLionel Sambuc void __vectorcall vector_func() { }
382*0a6a1f1dSLionel Sambuc // CHECK-DAG: @"\01?vector_func@@YQXXZ"
383