blob: 3f80e54f4334da78a03a9f5179dd016c5d678ff3 [file] [log] [blame]
Reid Klecknerd6a08d12013-05-14 20:30:42 +00001// RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
2// RUN: %clang_cc1 -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"
Timur Iskhodzhanov79b7cc52012-11-26 08:55:48 +00006// CHECK: @"\01?anonymous@?A@N@@3HA"
Charles Davis570d2762010-06-12 08:11:16 +00007// CHECK: @c
Charles Davisb021f8b2010-06-14 05:29:01 +00008// CHECK: @"\01?d@foo@@0FB"
9// CHECK: @"\01?e@foo@@1JC"
10// CHECK: @"\01?f@foo@@2DD"
Charles Davisc62458f2010-06-18 07:51:00 +000011// CHECK: @"\01?g@bar@@2HA"
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000012// CHECK: @"\01?h1@@3QAHA"
13// CHECK: @"\01?h2@@3QBHB"
Charles Davis08778262010-07-03 08:15:16 +000014// CHECK: @"\01?i@@3PAY0BE@HA"
Charles Davis1139da12010-07-03 05:53:41 +000015// CHECK: @"\01?j@@3P6GHCE@ZA"
Charles Daviscd712cb2010-07-03 08:01:32 +000016// CHECK: @"\01?k@@3PTfoo@@DA"
Charles Davisee743f92010-11-09 18:04:24 +000017// CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
Richard Smithc0838d22012-06-08 00:37:04 +000018// CHECK: @"\01?color1@@3PANA"
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +000019// CHECK: @"\01?color2@@3QBNB"
Peter Collingbourneb70d1c32013-04-25 04:25:40 +000020// CHECK: @"\01?color3@@3QAY02$$CBNA"
21// CHECK: @"\01?color4@@3QAY02$$CBNA"
Charles Davis570d2762010-06-12 08:11:16 +000022
23int a;
Charles Davise60cea82010-06-11 03:07:32 +000024
Timur Iskhodzhanov79b7cc52012-11-26 08:55:48 +000025namespace N {
26 int b;
27
28 namespace {
29 int anonymous;
30 }
31}
Charles Davis570d2762010-06-12 08:11:16 +000032
33static int c;
Timur Iskhodzhanov79b7cc52012-11-26 08:55:48 +000034int _c(void) {return N::anonymous + c;}
Charles Davis65161d12010-06-16 05:33:16 +000035// CHECK: @"\01?_c@@YAHXZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000036// X64: @"\01?_c@@YAHXZ"
Charles Davis570d2762010-06-12 08:11:16 +000037
Charles Davisb021f8b2010-06-14 05:29:01 +000038class foo {
39 static const short d;
40protected:
41 static volatile long e;
42public:
43 static const volatile char f;
Charles Davis21e2a7e2010-06-17 06:47:31 +000044 int operator+(int a);
Michael J. Spencer50118da2011-12-01 09:55:00 +000045 foo(){}
46//CHECK: @"\01??0foo@@QAE@XZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000047//X64: @"\01??0foo@@QEAA@XZ"
Michael J. Spencer50118da2011-12-01 09:55:00 +000048
49 ~foo(){}
50//CHECK: @"\01??1foo@@QAE@XZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000051//X64: @"\01??1foo@@QEAA@XZ
Michael J. Spencer50118da2011-12-01 09:55:00 +000052
53 foo(int i){}
54//CHECK: @"\01??0foo@@QAE@H@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000055//X64: @"\01??0foo@@QEAA@H@Z"
Michael J. Spencer50118da2011-12-01 09:55:00 +000056
57 foo(char *q){}
58//CHECK: @"\01??0foo@@QAE@PAD@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000059//X64: @"\01??0foo@@QEAA@PEAD@Z"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000060
61 static foo* static_method() { return 0; }
62
Michael J. Spencer50118da2011-12-01 09:55:00 +000063}f,s1(1),s2((char*)0);
Charles Davisb021f8b2010-06-14 05:29:01 +000064
Richard Smithc0838d22012-06-08 00:37:04 +000065typedef foo (foo2);
66
Charles Davisc62458f2010-06-18 07:51:00 +000067struct bar {
68 static int g;
69};
70
71union baz {
72 int a;
73 char b;
74 double c;
75};
76
77enum quux {
78 qone,
79 qtwo,
80 qthree
81};
82
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000083foo bar() { return foo(); }
84//CHECK: @"\01?bar@@YA?AVfoo@@XZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000085//X64: @"\01?bar@@YA?AVfoo@@XZ"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000086
87int foo::operator+(int a) {
88//CHECK: @"\01??Hfoo@@QAEHH@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000089//X64: @"\01??Hfoo@@QEAAHH@Z"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000090
91 foo::static_method();
92//CHECK: @"\01?static_method@foo@@SAPAV1@XZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +000093//X64: @"\01?static_method@foo@@SAPEAV1@XZ"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000094 bar();
95 return a;
96}
Charles Davis21e2a7e2010-06-17 06:47:31 +000097
Charles Davisb021f8b2010-06-14 05:29:01 +000098const short foo::d = 0;
99volatile long foo::e;
100const volatile char foo::f = 'C';
101
Charles Davisc62458f2010-06-18 07:51:00 +0000102int bar::g;
103
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000104extern int * const h1 = &a;
105extern const int * const h2 = &a;
Charles Davis3a0d41d2010-06-26 03:50:05 +0000106
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000107int i[10][20];
108
Charles Davis1139da12010-07-03 05:53:41 +0000109int (__stdcall *j)(signed char, unsigned char);
110
Richard Smithc0838d22012-06-08 00:37:04 +0000111const volatile char foo2::*k;
Charles Daviscd712cb2010-07-03 08:01:32 +0000112
Richard Smithc0838d22012-06-08 00:37:04 +0000113int (foo2::*l)(int);
Charles Daviscd712cb2010-07-03 08:01:32 +0000114
Charles Davis65161d12010-06-16 05:33:16 +0000115// Static functions are mangled, too.
116// Also make sure calling conventions, arglists, and throw specs work.
117static void __stdcall alpha(float a, double b) throw() {}
118bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
Charles Davis3a0d41d2010-06-26 03:50:05 +0000119// CHECK: @"\01?beta@@YI_N_J_W@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000120// X64: @"\01?beta@@YA_N_J_W@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000121 alpha(0.f, 0.0);
122 return false;
123}
124
Charles Davis3a0d41d2010-06-26 03:50:05 +0000125// CHECK: @"\01?alpha@@YGXMN@Z"
Aaron Ballman82bfa192012-10-02 14:26:08 +0000126// X64: @"\01?alpha@@YAXMN@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000127
Charles Davisc62458f2010-06-18 07:51:00 +0000128// Make sure tag-type mangling works.
129void gamma(class foo, struct bar, union baz, enum quux) {}
130// CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000131// X64: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
Charles Davisc62458f2010-06-18 07:51:00 +0000132
Charles Davis3a0d41d2010-06-26 03:50:05 +0000133// Make sure pointer/reference-type mangling works.
134void delta(int * const a, const long &) {}
135// CHECK: @"\01?delta@@YAXQAHABJ@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000136// X64: @"\01?delta@@YAXQEAHAEBJ@Z"
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000137
Charles Davis4d254832010-07-03 16:56:59 +0000138// Array mangling.
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000139void epsilon(int a[][10][20]) {}
Charles Davis08778262010-07-03 08:15:16 +0000140// CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000141// X64: @"\01?epsilon@@YAXQEAY19BE@H@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000142
Timur Iskhodzhanovbae11d82012-07-26 13:41:30 +0000143void zeta(int (*)(int, int)) {}
144// CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000145// X64: @"\01?zeta@@YAXP6AHHH@Z@Z"
Timur Iskhodzhanovbae11d82012-07-26 13:41:30 +0000146
147// Blocks mangling (Clang extension). A block should be mangled slightly
148// differently from a similar function pointer.
149void eta(int (^)(int, int)) {}
150// CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000151
John McCall2612e9f2012-08-25 01:12:56 +0000152typedef int theta_arg(int,int);
153void theta(theta_arg^ block) {}
154// CHECK: @"\01?theta@@YAXP_EAHHH@Z@Z"
155
John McCall3a8ac072012-05-01 02:33:44 +0000156void operator_new_delete() {
157 char *ptr = new char;
158// CHECK: @"\01??2@YAPAXI@Z"
159
160 delete ptr;
161// CHECK: @"\01??3@YAXPAX@Z"
162
163 char *array = new char[42];
164// CHECK: @"\01??_U@YAPAXI@Z"
165
John McCalle2b45e22012-05-01 05:23:51 +0000166 delete [] array;
167// CHECK: @"\01??_V@YAXPAX@Z"
John McCall3a8ac072012-05-01 02:33:44 +0000168}
Richard Smithbd1d18e2012-06-04 22:46:59 +0000169
170// PR13022
171void (redundant_parens)();
172void redundant_parens_use() { redundant_parens(); }
173// CHECK: @"\01?redundant_parens@@YAXXZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000174// X64: @"\01?redundant_parens@@YAXXZ"
Richard Smithc0838d22012-06-08 00:37:04 +0000175
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000176// PR13047
Richard Smithc0838d22012-06-08 00:37:04 +0000177typedef double RGB[3];
178RGB color1;
179extern const RGB color2 = {};
Timur Iskhodzhanova5427442012-07-23 09:32:54 +0000180extern RGB const color3[5] = {};
181extern RGB const ((color4)[5]) = {};
Richard Smith06e767d2012-06-21 02:52:27 +0000182
183// PR12603
184enum E {};
185// CHECK: "\01?fooE@@YA?AW4E@@XZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000186// X64: "\01?fooE@@YA?AW4E@@XZ"
Richard Smith06e767d2012-06-21 02:52:27 +0000187E fooE() { return E(); }
188
189class X {};
190// CHECK: "\01?fooX@@YA?AVX@@XZ"
Reid Klecknerd6a08d12013-05-14 20:30:42 +0000191// X64: "\01?fooX@@YA?AVX@@XZ"
Richard Smith06e767d2012-06-21 02:52:27 +0000192X fooX() { return X(); }
Timur Iskhodzhanova04ca5c2012-09-03 09:08:10 +0000193
194namespace PR13182 {
195 extern char s0[];
196 // CHECK: @"\01?s0@PR13182@@3PADA"
197 extern char s1[42];
198 // CHECK: @"\01?s1@PR13182@@3PADA"
199 extern const char s2[];
200 // CHECK: @"\01?s2@PR13182@@3QBDB"
201 extern const char s3[42];
202 // CHECK: @"\01?s3@PR13182@@3QBDB"
203 extern volatile char s4[];
204 // CHECK: @"\01?s4@PR13182@@3RCDC"
205 extern const volatile char s5[];
206 // CHECK: @"\01?s5@PR13182@@3SDDD"
207 extern const char* const* s6;
208 // CHECK: @"\01?s6@PR13182@@3PBQBDB"
209
210 char foo() {
211 return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
212 }
213}