blob: 6964581f92007c509f09ae3f6a2c4704312273a4 [file] [log] [blame]
Charles Davisee743f92010-11-09 18:04:24 +00001// RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
Charles Davise60cea82010-06-11 03:07:32 +00002
Charles Davisb021f8b2010-06-14 05:29:01 +00003// CHECK: @"\01?a@@3HA"
4// CHECK: @"\01?b@N@@3HA"
Charles Davis570d2762010-06-12 08:11:16 +00005// CHECK: @c
Charles Davisb021f8b2010-06-14 05:29:01 +00006// CHECK: @"\01?d@foo@@0FB"
7// CHECK: @"\01?e@foo@@1JC"
8// CHECK: @"\01?f@foo@@2DD"
Charles Davisc62458f2010-06-18 07:51:00 +00009// CHECK: @"\01?g@bar@@2HA"
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000010// CHECK: @"\01?h1@@3QAHA"
11// CHECK: @"\01?h2@@3QBHB"
Charles Davis08778262010-07-03 08:15:16 +000012// CHECK: @"\01?i@@3PAY0BE@HA"
Charles Davis1139da12010-07-03 05:53:41 +000013// CHECK: @"\01?j@@3P6GHCE@ZA"
Charles Daviscd712cb2010-07-03 08:01:32 +000014// CHECK: @"\01?k@@3PTfoo@@DA"
Charles Davisee743f92010-11-09 18:04:24 +000015// CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
Richard Smithc0838d22012-06-08 00:37:04 +000016// CHECK: @"\01?color1@@3PANA"
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000017// CHECK: @"\01?color2@@3QBNB"
Timur Iskhodzhanova5427442012-07-23 09:32:54 +000018
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000019// FIXME: The following three tests currently fail, see http://llvm.org/PR13182
Timur Iskhodzhanova5427442012-07-23 09:32:54 +000020// Replace "CHECK-NOT" with "CHECK" when it is fixed.
Timur Iskhodzhanov1cc9be02012-07-23 09:43:03 +000021// CHECK-NOT: @"\01?color3@@3QAY02$$CBNA"
22// CHECK-NOT: @"\01?color4@@3QAY02$$CBNA"
Charles Davis570d2762010-06-12 08:11:16 +000023
24int a;
Charles Davise60cea82010-06-11 03:07:32 +000025
26namespace N { int b; }
Charles Davis570d2762010-06-12 08:11:16 +000027
28static int c;
29int _c(void) {return c;}
Charles Davis65161d12010-06-16 05:33:16 +000030// CHECK: @"\01?_c@@YAHXZ"
Charles Davis570d2762010-06-12 08:11:16 +000031
Charles Davisb021f8b2010-06-14 05:29:01 +000032class foo {
33 static const short d;
34protected:
35 static volatile long e;
36public:
37 static const volatile char f;
Charles Davis21e2a7e2010-06-17 06:47:31 +000038 int operator+(int a);
Michael J. Spencer50118da2011-12-01 09:55:00 +000039 foo(){}
40//CHECK: @"\01??0foo@@QAE@XZ"
41
42 ~foo(){}
43//CHECK: @"\01??1foo@@QAE@XZ"
44
45 foo(int i){}
46//CHECK: @"\01??0foo@@QAE@H@Z"
47
48 foo(char *q){}
49//CHECK: @"\01??0foo@@QAE@PAD@Z"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000050
51 static foo* static_method() { return 0; }
52
Michael J. Spencer50118da2011-12-01 09:55:00 +000053}f,s1(1),s2((char*)0);
Charles Davisb021f8b2010-06-14 05:29:01 +000054
Richard Smithc0838d22012-06-08 00:37:04 +000055typedef foo (foo2);
56
Charles Davisc62458f2010-06-18 07:51:00 +000057struct bar {
58 static int g;
59};
60
61union baz {
62 int a;
63 char b;
64 double c;
65};
66
67enum quux {
68 qone,
69 qtwo,
70 qthree
71};
72
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000073foo bar() { return foo(); }
74//CHECK: @"\01?bar@@YA?AVfoo@@XZ"
75
76int 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}
Charles Davis21e2a7e2010-06-17 06:47:31 +000084
Charles Davisb021f8b2010-06-14 05:29:01 +000085const short foo::d = 0;
86volatile long foo::e;
87const volatile char foo::f = 'C';
88
Charles Davisc62458f2010-06-18 07:51:00 +000089int bar::g;
90
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000091extern int * const h1 = &a;
92extern const int * const h2 = &a;
Charles Davis3a0d41d2010-06-26 03:50:05 +000093
Charles Davis0b8fe8c2010-06-30 08:09:57 +000094int i[10][20];
95
Charles Davis1139da12010-07-03 05:53:41 +000096int (__stdcall *j)(signed char, unsigned char);
97
Richard Smithc0838d22012-06-08 00:37:04 +000098const volatile char foo2::*k;
Charles Daviscd712cb2010-07-03 08:01:32 +000099
Richard Smithc0838d22012-06-08 00:37:04 +0000100int (foo2::*l)(int);
Charles Daviscd712cb2010-07-03 08:01:32 +0000101
Charles Davis65161d12010-06-16 05:33:16 +0000102// Static functions are mangled, too.
103// Also make sure calling conventions, arglists, and throw specs work.
104static void __stdcall alpha(float a, double b) throw() {}
105bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
Charles Davis3a0d41d2010-06-26 03:50:05 +0000106// CHECK: @"\01?beta@@YI_N_J_W@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000107 alpha(0.f, 0.0);
108 return false;
109}
110
Charles Davis3a0d41d2010-06-26 03:50:05 +0000111// CHECK: @"\01?alpha@@YGXMN@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000112
Charles Davisc62458f2010-06-18 07:51:00 +0000113// Make sure tag-type mangling works.
114void gamma(class foo, struct bar, union baz, enum quux) {}
115// CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
116
Charles Davis3a0d41d2010-06-26 03:50:05 +0000117// Make sure pointer/reference-type mangling works.
118void delta(int * const a, const long &) {}
119// CHECK: @"\01?delta@@YAXQAHABJ@Z"
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000120
Charles Davis4d254832010-07-03 16:56:59 +0000121// Array mangling.
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000122void epsilon(int a[][10][20]) {}
Charles Davis08778262010-07-03 08:15:16 +0000123// CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000124
Timur Iskhodzhanovbae11d82012-07-26 13:41:30 +0000125void 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.
130void eta(int (^)(int, int)) {}
131// CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000132
John McCall2612e9f2012-08-25 01:12:56 +0000133typedef int theta_arg(int,int);
134void theta(theta_arg^ block) {}
135// CHECK: @"\01?theta@@YAXP_EAHHH@Z@Z"
136
John McCall3a8ac072012-05-01 02:33:44 +0000137void 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
John McCalle2b45e22012-05-01 05:23:51 +0000147 delete [] array;
148// CHECK: @"\01??_V@YAXPAX@Z"
John McCall3a8ac072012-05-01 02:33:44 +0000149}
Richard Smithbd1d18e2012-06-04 22:46:59 +0000150
151// PR13022
152void (redundant_parens)();
153void redundant_parens_use() { redundant_parens(); }
154// CHECK: @"\01?redundant_parens@@YAXXZ"
Richard Smithc0838d22012-06-08 00:37:04 +0000155
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000156// PR13047
Richard Smithc0838d22012-06-08 00:37:04 +0000157typedef double RGB[3];
158RGB color1;
159extern const RGB color2 = {};
Timur Iskhodzhanova5427442012-07-23 09:32:54 +0000160extern RGB const color3[5] = {};
161extern RGB const ((color4)[5]) = {};
Richard Smith06e767d2012-06-21 02:52:27 +0000162
163// PR12603
164enum E {};
165// CHECK: "\01?fooE@@YA?AW4E@@XZ"
166E fooE() { return E(); }
167
168class X {};
169// CHECK: "\01?fooX@@YA?AVX@@XZ"
170X fooX() { return X(); }
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000171
172namespace 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
188 char foo() {
189 return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
190 }
191}