blob: 0edb4b4339aa68903ecb9591149c8da4dd825f5c [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
Aaron Ballman82bfa192012-10-02 14:26:08 +00002// RUN: %clang_cc1 -fms-compatibility -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s
Charles Davise60cea82010-06-11 03:07:32 +00003
Charles Davisb021f8b2010-06-14 05:29:01 +00004// CHECK: @"\01?a@@3HA"
5// CHECK: @"\01?b@N@@3HA"
Charles Davis570d2762010-06-12 08:11:16 +00006// CHECK: @c
Charles Davisb021f8b2010-06-14 05:29:01 +00007// CHECK: @"\01?d@foo@@0FB"
8// CHECK: @"\01?e@foo@@1JC"
9// CHECK: @"\01?f@foo@@2DD"
Charles Davisc62458f2010-06-18 07:51:00 +000010// CHECK: @"\01?g@bar@@2HA"
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000011// CHECK: @"\01?h1@@3QAHA"
12// CHECK: @"\01?h2@@3QBHB"
Charles Davis08778262010-07-03 08:15:16 +000013// CHECK: @"\01?i@@3PAY0BE@HA"
Charles Davis1139da12010-07-03 05:53:41 +000014// CHECK: @"\01?j@@3P6GHCE@ZA"
Charles Daviscd712cb2010-07-03 08:01:32 +000015// CHECK: @"\01?k@@3PTfoo@@DA"
Charles Davisee743f92010-11-09 18:04:24 +000016// CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
Richard Smithc0838d22012-06-08 00:37:04 +000017// CHECK: @"\01?color1@@3PANA"
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000018// CHECK: @"\01?color2@@3QBNB"
Timur Iskhodzhanova5427442012-07-23 09:32:54 +000019
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000020// FIXME: The following three tests currently fail, see http://llvm.org/PR13182
Timur Iskhodzhanova5427442012-07-23 09:32:54 +000021// Replace "CHECK-NOT" with "CHECK" when it is fixed.
Timur Iskhodzhanov1cc9be02012-07-23 09:43:03 +000022// CHECK-NOT: @"\01?color3@@3QAY02$$CBNA"
23// CHECK-NOT: @"\01?color4@@3QAY02$$CBNA"
Charles Davis570d2762010-06-12 08:11:16 +000024
25int a;
Charles Davise60cea82010-06-11 03:07:32 +000026
27namespace N { int b; }
Charles Davis570d2762010-06-12 08:11:16 +000028
29static int c;
30int _c(void) {return c;}
Charles Davis65161d12010-06-16 05:33:16 +000031// CHECK: @"\01?_c@@YAHXZ"
Charles Davis570d2762010-06-12 08:11:16 +000032
Charles Davisb021f8b2010-06-14 05:29:01 +000033class foo {
34 static const short d;
35protected:
36 static volatile long e;
37public:
38 static const volatile char f;
Charles Davis21e2a7e2010-06-17 06:47:31 +000039 int operator+(int a);
Michael J. Spencer50118da2011-12-01 09:55:00 +000040 foo(){}
41//CHECK: @"\01??0foo@@QAE@XZ"
42
43 ~foo(){}
44//CHECK: @"\01??1foo@@QAE@XZ"
45
46 foo(int i){}
47//CHECK: @"\01??0foo@@QAE@H@Z"
48
49 foo(char *q){}
50//CHECK: @"\01??0foo@@QAE@PAD@Z"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000051
52 static foo* static_method() { return 0; }
53
Michael J. Spencer50118da2011-12-01 09:55:00 +000054}f,s1(1),s2((char*)0);
Charles Davisb021f8b2010-06-14 05:29:01 +000055
Richard Smithc0838d22012-06-08 00:37:04 +000056typedef foo (foo2);
57
Charles Davisc62458f2010-06-18 07:51:00 +000058struct bar {
59 static int g;
60};
61
62union baz {
63 int a;
64 char b;
65 double c;
66};
67
68enum quux {
69 qone,
70 qtwo,
71 qthree
72};
73
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000074foo bar() { return foo(); }
75//CHECK: @"\01?bar@@YA?AVfoo@@XZ"
76
77int foo::operator+(int a) {
78//CHECK: @"\01??Hfoo@@QAEHH@Z"
79
80 foo::static_method();
81//CHECK: @"\01?static_method@foo@@SAPAV1@XZ"
82 bar();
83 return a;
84}
Charles Davis21e2a7e2010-06-17 06:47:31 +000085
Charles Davisb021f8b2010-06-14 05:29:01 +000086const short foo::d = 0;
87volatile long foo::e;
88const volatile char foo::f = 'C';
89
Charles Davisc62458f2010-06-18 07:51:00 +000090int bar::g;
91
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000092extern int * const h1 = &a;
93extern const int * const h2 = &a;
Charles Davis3a0d41d2010-06-26 03:50:05 +000094
Charles Davis0b8fe8c2010-06-30 08:09:57 +000095int i[10][20];
96
Charles Davis1139da12010-07-03 05:53:41 +000097int (__stdcall *j)(signed char, unsigned char);
98
Richard Smithc0838d22012-06-08 00:37:04 +000099const volatile char foo2::*k;
Charles Daviscd712cb2010-07-03 08:01:32 +0000100
Richard Smithc0838d22012-06-08 00:37:04 +0000101int (foo2::*l)(int);
Charles Daviscd712cb2010-07-03 08:01:32 +0000102
Charles Davis65161d12010-06-16 05:33:16 +0000103// Static functions are mangled, too.
104// Also make sure calling conventions, arglists, and throw specs work.
105static void __stdcall alpha(float a, double b) throw() {}
106bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
Charles Davis3a0d41d2010-06-26 03:50:05 +0000107// CHECK: @"\01?beta@@YI_N_J_W@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000108 alpha(0.f, 0.0);
109 return false;
110}
111
Charles Davis3a0d41d2010-06-26 03:50:05 +0000112// CHECK: @"\01?alpha@@YGXMN@Z"
Aaron Ballman82bfa192012-10-02 14:26:08 +0000113// X64: @"\01?alpha@@YAXMN@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000114
Charles Davisc62458f2010-06-18 07:51:00 +0000115// Make sure tag-type mangling works.
116void gamma(class foo, struct bar, union baz, enum quux) {}
117// CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
118
Charles Davis3a0d41d2010-06-26 03:50:05 +0000119// Make sure pointer/reference-type mangling works.
120void delta(int * const a, const long &) {}
121// CHECK: @"\01?delta@@YAXQAHABJ@Z"
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000122
Charles Davis4d254832010-07-03 16:56:59 +0000123// Array mangling.
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000124void epsilon(int a[][10][20]) {}
Charles Davis08778262010-07-03 08:15:16 +0000125// CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000126
Timur Iskhodzhanovbae11d82012-07-26 13:41:30 +0000127void zeta(int (*)(int, int)) {}
128// CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z"
129
130// Blocks mangling (Clang extension). A block should be mangled slightly
131// differently from a similar function pointer.
132void eta(int (^)(int, int)) {}
133// CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000134
John McCall2612e9f2012-08-25 01:12:56 +0000135typedef int theta_arg(int,int);
136void theta(theta_arg^ block) {}
137// CHECK: @"\01?theta@@YAXP_EAHHH@Z@Z"
138
John McCall3a8ac072012-05-01 02:33:44 +0000139void operator_new_delete() {
140 char *ptr = new char;
141// CHECK: @"\01??2@YAPAXI@Z"
142
143 delete ptr;
144// CHECK: @"\01??3@YAXPAX@Z"
145
146 char *array = new char[42];
147// CHECK: @"\01??_U@YAPAXI@Z"
148
John McCalle2b45e22012-05-01 05:23:51 +0000149 delete [] array;
150// CHECK: @"\01??_V@YAXPAX@Z"
John McCall3a8ac072012-05-01 02:33:44 +0000151}
Richard Smithbd1d18e2012-06-04 22:46:59 +0000152
153// PR13022
154void (redundant_parens)();
155void redundant_parens_use() { redundant_parens(); }
156// CHECK: @"\01?redundant_parens@@YAXXZ"
Richard Smithc0838d22012-06-08 00:37:04 +0000157
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000158// PR13047
Richard Smithc0838d22012-06-08 00:37:04 +0000159typedef double RGB[3];
160RGB color1;
161extern const RGB color2 = {};
Timur Iskhodzhanova5427442012-07-23 09:32:54 +0000162extern RGB const color3[5] = {};
163extern RGB const ((color4)[5]) = {};
Richard Smith06e767d2012-06-21 02:52:27 +0000164
165// PR12603
166enum E {};
167// CHECK: "\01?fooE@@YA?AW4E@@XZ"
168E fooE() { return E(); }
169
170class X {};
171// CHECK: "\01?fooX@@YA?AVX@@XZ"
172X fooX() { return X(); }
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000173
174namespace PR13182 {
175 extern char s0[];
176 // CHECK: @"\01?s0@PR13182@@3PADA"
177 extern char s1[42];
178 // CHECK: @"\01?s1@PR13182@@3PADA"
179 extern const char s2[];
180 // CHECK: @"\01?s2@PR13182@@3QBDB"
181 extern const char s3[42];
182 // CHECK: @"\01?s3@PR13182@@3QBDB"
183 extern volatile char s4[];
184 // CHECK: @"\01?s4@PR13182@@3RCDC"
185 extern const volatile char s5[];
186 // CHECK: @"\01?s5@PR13182@@3SDDD"
187 extern const char* const* s6;
188 // CHECK: @"\01?s6@PR13182@@3PBQBDB"
189
190 char foo() {
191 return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
192 }
193}