mangle-ms-arg-qualifiers.cpp
7.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 | FileCheck %s
// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 | FileCheck -check-prefix=X64 %s
void foo(const unsigned int) {}
// CHECK: "?foo@@YAXI@Z"
// X64: "?foo@@YAXI@Z"
void foo(const double) {}
// CHECK: "?foo@@YAXN@Z"
// X64: "?foo@@YAXN@Z"
void bar(const volatile double) {}
// CHECK: "?bar@@YAXN@Z"
// X64: "?bar@@YAXN@Z"
void foo_pad(char * x) {}
// CHECK: "?foo_pad@@YAXPAD@Z"
// X64: "?foo_pad@@YAXPEAD@Z"
void foo_pbd(const char * x) {}
// CHECK: "?foo_pbd@@YAXPBD@Z"
// X64: "?foo_pbd@@YAXPEBD@Z"
void foo_pcd(volatile char * x) {}
// CHECK: "?foo_pcd@@YAXPCD@Z"
// X64: "?foo_pcd@@YAXPECD@Z"
void foo_qad(char * const x) {}
// CHECK: "?foo_qad@@YAXQAD@Z"
// X64: "?foo_qad@@YAXQEAD@Z"
void foo_rad(char * volatile x) {}
// CHECK: "?foo_rad@@YAXRAD@Z"
// X64: "?foo_rad@@YAXREAD@Z"
void foo_sad(char * const volatile x) {}
// CHECK: "?foo_sad@@YAXSAD@Z"
// X64: "?foo_sad@@YAXSEAD@Z"
void foo_piad(char * __restrict x) {}
// CHECK: "?foo_piad@@YAXPIAD@Z"
// X64: "?foo_piad@@YAXPEIAD@Z"
void foo_qiad(char * const __restrict x) {}
// CHECK: "?foo_qiad@@YAXQIAD@Z"
// X64: "?foo_qiad@@YAXQEIAD@Z"
void foo_riad(char * volatile __restrict x) {}
// CHECK: "?foo_riad@@YAXRIAD@Z"
// X64: "?foo_riad@@YAXREIAD@Z"
void foo_siad(char * const volatile __restrict x) {}
// CHECK: "?foo_siad@@YAXSIAD@Z"
// X64: "?foo_siad@@YAXSEIAD@Z"
void foo_papad(char ** x) {}
// CHECK: "?foo_papad@@YAXPAPAD@Z"
// X64: "?foo_papad@@YAXPEAPEAD@Z"
void foo_papbd(char const ** x) {}
// CHECK: "?foo_papbd@@YAXPAPBD@Z"
// X64: "?foo_papbd@@YAXPEAPEBD@Z"
void foo_papcd(char volatile ** x) {}
// CHECK: "?foo_papcd@@YAXPAPCD@Z"
// X64: "?foo_papcd@@YAXPEAPECD@Z"
void foo_pbqad(char * const* x) {}
// CHECK: "?foo_pbqad@@YAXPBQAD@Z"
// X64: "?foo_pbqad@@YAXPEBQEAD@Z"
void foo_pcrad(char * volatile* x) {}
// CHECK: "?foo_pcrad@@YAXPCRAD@Z"
// X64: "?foo_pcrad@@YAXPECREAD@Z"
void foo_qapad(char ** const x) {}
// CHECK: "?foo_qapad@@YAXQAPAD@Z"
// X64: "?foo_qapad@@YAXQEAPEAD@Z"
void foo_rapad(char ** volatile x) {}
// CHECK: "?foo_rapad@@YAXRAPAD@Z"
// X64: "?foo_rapad@@YAXREAPEAD@Z"
void foo_pbqbd(const char * const* x) {}
// CHECK: "?foo_pbqbd@@YAXPBQBD@Z"
// X64: "?foo_pbqbd@@YAXPEBQEBD@Z"
void foo_pbqcd(volatile char * const* x) {}
// CHECK: "?foo_pbqcd@@YAXPBQCD@Z"
// X64: "?foo_pbqcd@@YAXPEBQECD@Z"
void foo_pcrbd(const char * volatile* x) {}
// CHECK: "?foo_pcrbd@@YAXPCRBD@Z"
// X64: "?foo_pcrbd@@YAXPECREBD@Z"
void foo_pcrcd(volatile char * volatile* x) {}
// CHECK: "?foo_pcrcd@@YAXPCRCD@Z"
// X64: "?foo_pcrcd@@YAXPECRECD@Z"
void foo_aad(char &x) {}
// CHECK: "?foo_aad@@YAXAAD@Z"
// X64: "?foo_aad@@YAXAEAD@Z"
void foo_abd(const char &x) {}
// CHECK: "?foo_abd@@YAXABD@Z"
// X64: "?foo_abd@@YAXAEBD@Z"
void foo_aapad(char *&x) {}
// CHECK: "?foo_aapad@@YAXAAPAD@Z"
// X64: "?foo_aapad@@YAXAEAPEAD@Z"
void foo_aapbd(const char *&x) {}
// CHECK: "?foo_aapbd@@YAXAAPBD@Z"
// X64: "?foo_aapbd@@YAXAEAPEBD@Z"
void foo_abqad(char * const &x) {}
// CHECK: "?foo_abqad@@YAXABQAD@Z"
// X64: "?foo_abqad@@YAXAEBQEAD@Z"
void foo_abqbd(const char * const &x) {}
// CHECK: "?foo_abqbd@@YAXABQBD@Z"
// X64: "?foo_abqbd@@YAXAEBQEBD@Z"
void foo_aay144h(int (&x)[5][5]) {}
// CHECK: "?foo_aay144h@@YAXAAY144H@Z"
// X64: "?foo_aay144h@@YAXAEAY144H@Z"
void foo_aay144cbh(const int (&x)[5][5]) {}
// CHECK: "?foo_aay144cbh@@YAXAAY144$$CBH@Z"
// X64: "?foo_aay144cbh@@YAXAEAY144$$CBH@Z"
void foo_qay144h(int (&&x)[5][5]) {}
// CHECK: "?foo_qay144h@@YAX$$QAY144H@Z"
// X64: "?foo_qay144h@@YAX$$QEAY144H@Z"
void foo_qay144cbh(const int (&&x)[5][5]) {}
// CHECK: "?foo_qay144cbh@@YAX$$QAY144$$CBH@Z"
// X64: "?foo_qay144cbh@@YAX$$QEAY144$$CBH@Z"
void foo_p6ahxz(int x()) {}
// CHECK: "?foo_p6ahxz@@YAXP6AHXZ@Z"
// X64: "?foo_p6ahxz@@YAXP6AHXZ@Z"
void foo_a6ahxz(int (&x)()) {}
// CHECK: "?foo_a6ahxz@@YAXA6AHXZ@Z"
// X64: "?foo_a6ahxz@@YAXA6AHXZ@Z"
void foo_q6ahxz(int (&&x)()) {}
// CHECK: "?foo_q6ahxz@@YAX$$Q6AHXZ@Z"
// X64: "?foo_q6ahxz@@YAX$$Q6AHXZ@Z"
void foo_qay04h(int x[5][5]) {}
// CHECK: "?foo_qay04h@@YAXQAY04H@Z"
// X64: "?foo_qay04h@@YAXQEAY04H@Z"
void foo_qay04cbh(const int x[5][5]) {}
// CHECK: "?foo_qay04cbh@@YAXQAY04$$CBH@Z"
// X64: "?foo_qay04cbh@@YAXQEAY04$$CBH@Z"
typedef double Vector[3];
void foo(Vector*) {}
// CHECK: "?foo@@YAXPAY02N@Z"
// X64: "?foo@@YAXPEAY02N@Z"
void foo(Vector) {}
// CHECK: "?foo@@YAXQAN@Z"
// X64: "?foo@@YAXQEAN@Z"
void foo_const(const Vector) {}
// CHECK: "?foo_const@@YAXQBN@Z"
// X64: "?foo_const@@YAXQEBN@Z"
void foo_volatile(volatile Vector) {}
// CHECK: "?foo_volatile@@YAXQCN@Z"
// X64: "?foo_volatile@@YAXQECN@Z"
void foo(Vector*, const Vector, const double) {}
// CHECK: "?foo@@YAXPAY02NQBNN@Z"
// X64: "?foo@@YAXPEAY02NQEBNN@Z"
typedef void (*ConstFunPtr)(int *const d);
void foo_fnptrconst(ConstFunPtr f) { }
// CHECK: "?foo_fnptrconst@@YAXP6AXQAH@Z@Z"
// X64: "?foo_fnptrconst@@YAXP6AXQEAH@Z@Z"
typedef void (*ArrayFunPtr)(int d[1]);
void foo_fnptrarray(ArrayFunPtr f) { }
// CHECK: "?foo_fnptrarray@@YAXP6AXQAH@Z@Z"
// X64: "?foo_fnptrarray@@YAXP6AXQEAH@Z@Z"
void foo_fnptrbackref1(ArrayFunPtr f1, ArrayFunPtr f2) { }
// CHECK: "?foo_fnptrbackref1@@YAXP6AXQAH@Z1@Z"
// X64: "?foo_fnptrbackref1@@YAXP6AXQEAH@Z1@Z"
void foo_fnptrbackref2(ArrayFunPtr f1, ConstFunPtr f2) { }
// CHECK: "?foo_fnptrbackref2@@YAXP6AXQAH@Z1@Z"
// X64: "?foo_fnptrbackref2@@YAXP6AXQEAH@Z1@Z"
typedef void (*NormalFunPtr)(int *d);
void foo_fnptrbackref3(ArrayFunPtr f1, NormalFunPtr f2) { }
// CHECK: "?foo_fnptrbackref3@@YAXP6AXQAH@Z1@Z"
// X64: "?foo_fnptrbackref3@@YAXP6AXQEAH@Z1@Z"
void foo_fnptrbackref4(NormalFunPtr f1, ArrayFunPtr f2) { }
// CHECK: "?foo_fnptrbackref4@@YAXP6AXPAH@Z1@Z"
// X64: "?foo_fnptrbackref4@@YAXP6AXPEAH@Z1@Z"
ArrayFunPtr ret_fnptrarray() { return 0; }
// CHECK: "?ret_fnptrarray@@YAP6AXQAH@ZXZ"
// X64: "?ret_fnptrarray@@YAP6AXQEAH@ZXZ"
// Test that we mangle the forward decl when we have a redeclaration with a
// slightly different type.
void mangle_fwd(char * const x);
void mangle_fwd(char * x) {}
// CHECK: "?mangle_fwd@@YAXQAD@Z"
// X64: "?mangle_fwd@@YAXQEAD@Z"
void mangle_no_fwd(char * x) {}
// CHECK: "?mangle_no_fwd@@YAXPAD@Z"
// X64: "?mangle_no_fwd@@YAXPEAD@Z"
// The first argument gets mangled as-if it were written "int *const"
// The second arg should not form a backref because it isn't qualified
void mangle_no_backref0(int[], int *) {}
// CHECK: "?mangle_no_backref0@@YAXQAHPAH@Z"
// X64: "?mangle_no_backref0@@YAXQEAHPEAH@Z"
void mangle_no_backref1(int[], int *const) {}
// CHECK: "?mangle_no_backref1@@YAXQAHQAH@Z"
// X64: "?mangle_no_backref1@@YAXQEAHQEAH@Z"
typedef void fun_type(void);
typedef void (*ptr_to_fun_type)(void);
// Pointer to function types don't backref with function types
void mangle_no_backref2(fun_type, ptr_to_fun_type) {}
// CHECK: "?mangle_no_backref2@@YAXP6AXXZP6AXXZ@Z"
// X64: "?mangle_no_backref2@@YAXP6AXXZP6AXXZ@Z"
void mangle_yes_backref0(int[], int []) {}
// CHECK: "?mangle_yes_backref0@@YAXQAH0@Z"
// X64: "?mangle_yes_backref0@@YAXQEAH0@Z"
void mangle_yes_backref1(int *const, int *const) {}
// CHECK: "?mangle_yes_backref1@@YAXQAH0@Z"
// X64: "?mangle_yes_backref1@@YAXQEAH0@Z"
void mangle_yes_backref2(fun_type *const[], ptr_to_fun_type const[]) {}
// CHECK: "?mangle_yes_backref2@@YAXQBQ6AXXZ0@Z"
// X64: "?mangle_yes_backref2@@YAXQEBQ6AXXZ0@Z"
void mangle_yes_backref3(ptr_to_fun_type *const, void (**const)(void)) {}
// CHECK: "?mangle_yes_backref3@@YAXQAP6AXXZ0@Z"
// X64: "?mangle_yes_backref3@@YAXQEAP6AXXZ0@Z"
void mangle_yes_backref4(int *const __restrict, int *const __restrict) {}
// CHECK: "?mangle_yes_backref4@@YAXQIAH0@Z"
// X64: "?mangle_yes_backref4@@YAXQEIAH0@Z"
struct S {};
void pr23325(const S[1], const S[]) {}
// CHECK: "?pr23325@@YAXQBUS@@0@Z"
// X64: "?pr23325@@YAXQEBUS@@0@Z"
void vla_arg(int i, int a[][i]) {}
// CHECK: "?vla_arg@@YAXHQAY0A@H@Z"
// X64: "?vla_arg@@YAXHQEAY0A@H@Z"