1 // RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
2
3 // CHECK: @"\01?a@@3HA"
4 // CHECK: @"\01?b@N@@3HA"
5 // CHECK: @c
6 // CHECK: @"\01?d@foo@@0FB"
7 // CHECK: @"\01?e@foo@@1JC"
8 // CHECK: @"\01?f@foo@@2DD"
9 // CHECK: @"\01?g@bar@@2HA"
10 // CHECK: @"\01?h1@@3QAHA"
11 // CHECK: @"\01?h2@@3QBHB"
12 // CHECK: @"\01?i@@3PAY0BE@HA"
13 // CHECK: @"\01?j@@3P6GHCE@ZA"
14 // CHECK: @"\01?k@@3PTfoo@@DA"
15 // CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
16 // CHECK: @"\01?color1@@3PANA"
17 // CHECK: @"\01?color2@@3QBNB"
18
19 // FIXME: The following three tests currently fail, see http://llvm.org/PR13182
20 // Replace "CHECK-NOT" with "CHECK" when it is fixed.
21 // CHECK-NOT: @"\01?color3@@3QAY02$$CBNA"
22 // CHECK-NOT: @"\01?color4@@3QAY02$$CBNA"
23
24 int a;
25
26 namespace N { int b; }
27
28 static int c;
_c(void)29 int _c(void) {return c;}
30 // CHECK: @"\01?_c@@YAHXZ"
31
32 class foo {
33 static const short d;
34 protected:
35 static volatile long e;
36 public:
37 static const volatile char f;
38 int operator+(int a);
foo()39 foo(){}
40 //CHECK: @"\01??0foo@@QAE@XZ"
41
~foo()42 ~foo(){}
43 //CHECK: @"\01??1foo@@QAE@XZ"
44
foo(int i)45 foo(int i){}
46 //CHECK: @"\01??0foo@@QAE@H@Z"
47
foo(char * q)48 foo(char *q){}
49 //CHECK: @"\01??0foo@@QAE@PAD@Z"
50
static_method()51 static foo* static_method() { return 0; }
52
53 }f,s1(1),s2((char*)0);
54
55 typedef foo (foo2);
56
57 struct bar {
58 static int g;
59 };
60
61 union baz {
62 int a;
63 char b;
64 double c;
65 };
66
67 enum quux {
68 qone,
69 qtwo,
70 qthree
71 };
72
bar()73 foo bar() { return foo(); }
74 //CHECK: @"\01?bar@@YA?AVfoo@@XZ"
75
operator +(int a)76 int foo::operator+(int a) {
77 //CHECK: @"\01??Hfoo@@QAEHH@Z"
78
79 foo::static_method();
80 //CHECK: @"\01?static_method@foo@@SAPAV1@XZ"
81 bar();
82 return a;
83 }
84
85 const short foo::d = 0;
86 volatile long foo::e;
87 const volatile char foo::f = 'C';
88
89 int bar::g;
90
91 extern int * const h1 = &a;
92 extern const int * const h2 = &a;
93
94 int i[10][20];
95
96 int (__stdcall *j)(signed char, unsigned char);
97
98 const volatile char foo2::*k;
99
100 int (foo2::*l)(int);
101
102 // Static functions are mangled, too.
103 // Also make sure calling conventions, arglists, and throw specs work.
alpha(float a,double b)104 static void __stdcall alpha(float a, double b) throw() {}
beta(long long a,wchar_t b)105 bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
106 // CHECK: @"\01?beta@@YI_N_J_W@Z"
107 alpha(0.f, 0.0);
108 return false;
109 }
110
111 // CHECK: @"\01?alpha@@YGXMN@Z"
112
113 // Make sure tag-type mangling works.
gamma(class foo,struct bar,union baz,enum quux)114 void gamma(class foo, struct bar, union baz, enum quux) {}
115 // CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
116
117 // Make sure pointer/reference-type mangling works.
delta(int * const a,const long &)118 void delta(int * const a, const long &) {}
119 // CHECK: @"\01?delta@@YAXQAHABJ@Z"
120
121 // Array mangling.
epsilon(int a[][10][20])122 void epsilon(int a[][10][20]) {}
123 // CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
124
zeta(int (*)(int,int))125 void zeta(int (*)(int, int)) {}
126 // CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z"
127
128 // Blocks mangling (Clang extension). A block should be mangled slightly
129 // differently from a similar function pointer.
130 void eta(int (^)(int, int)) {}
131 // CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z"
132
133 typedef int theta_arg(int,int);
134 void theta(theta_arg^ block) {}
135 // CHECK: @"\01?theta@@YAXP_EAHHH@Z@Z"
136
operator_new_delete()137 void operator_new_delete() {
138 char *ptr = new char;
139 // CHECK: @"\01??2@YAPAXI@Z"
140
141 delete ptr;
142 // CHECK: @"\01??3@YAXPAX@Z"
143
144 char *array = new char[42];
145 // CHECK: @"\01??_U@YAPAXI@Z"
146
147 delete [] array;
148 // CHECK: @"\01??_V@YAXPAX@Z"
149 }
150
151 // PR13022
152 void (redundant_parens)();
redundant_parens_use()153 void redundant_parens_use() { redundant_parens(); }
154 // CHECK: @"\01?redundant_parens@@YAXXZ"
155
156 // PR13047
157 typedef double RGB[3];
158 RGB color1;
159 extern const RGB color2 = {};
160 extern RGB const color3[5] = {};
161 extern RGB const ((color4)[5]) = {};
162
163 // PR12603
164 enum E {};
165 // CHECK: "\01?fooE@@YA?AW4E@@XZ"
fooE()166 E fooE() { return E(); }
167
168 class X {};
169 // CHECK: "\01?fooX@@YA?AVX@@XZ"
fooX()170 X fooX() { return X(); }
171
172 namespace PR13182 {
173 extern char s0[];
174 // CHECK: @"\01?s0@PR13182@@3PADA"
175 extern char s1[42];
176 // CHECK: @"\01?s1@PR13182@@3PADA"
177 extern const char s2[];
178 // CHECK: @"\01?s2@PR13182@@3QBDB"
179 extern const char s3[42];
180 // CHECK: @"\01?s3@PR13182@@3QBDB"
181 extern volatile char s4[];
182 // CHECK: @"\01?s4@PR13182@@3RCDC"
183 extern const volatile char s5[];
184 // CHECK: @"\01?s5@PR13182@@3SDDD"
185 extern const char* const* s6;
186 // CHECK: @"\01?s6@PR13182@@3PBQBDB"
187
foo()188 char foo() {
189 return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
190 }
191 }
192