blob: f392c1701edd4310c5cef79d6a66df10d418a225 [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"
Charles Davis3a0d41d2010-06-26 03:50:05 +000010// CHECK: @"\01?h@@3QAHA"
Charles Davis08778262010-07-03 08:15:16 +000011// CHECK: @"\01?i@@3PAY0BE@HA"
Charles Davis1139da12010-07-03 05:53:41 +000012// CHECK: @"\01?j@@3P6GHCE@ZA"
Charles Daviscd712cb2010-07-03 08:01:32 +000013// CHECK: @"\01?k@@3PTfoo@@DA"
Charles Davisee743f92010-11-09 18:04:24 +000014// CHECK: @"\01?l@@3P8foo@@AEHH@ZA"
Richard Smithc0838d22012-06-08 00:37:04 +000015// CHECK: @"\01?color1@@3PANA"
Timur Iskhodzhanova5427442012-07-23 09:32:54 +000016
17// FIXME: The following three tests currently fail, see PR13182.
18// Replace "CHECK-NOT" with "CHECK" when it is fixed.
Timur Iskhodzhanov1cc9be02012-07-23 09:43:03 +000019// CHECK-NOT: @"\01?color2@@3QBNB"
20// CHECK-NOT: @"\01?color3@@3QAY02$$CBNA"
21// CHECK-NOT: @"\01?color4@@3QAY02$$CBNA"
Charles Davis570d2762010-06-12 08:11:16 +000022
23int a;
Charles Davise60cea82010-06-11 03:07:32 +000024
25namespace N { int b; }
Charles Davis570d2762010-06-12 08:11:16 +000026
27static int c;
28int _c(void) {return c;}
Charles Davis65161d12010-06-16 05:33:16 +000029// CHECK: @"\01?_c@@YAHXZ"
Charles Davis570d2762010-06-12 08:11:16 +000030
Charles Davisb021f8b2010-06-14 05:29:01 +000031class foo {
32 static const short d;
33protected:
34 static volatile long e;
35public:
36 static const volatile char f;
Charles Davis21e2a7e2010-06-17 06:47:31 +000037 int operator+(int a);
Michael J. Spencer50118da2011-12-01 09:55:00 +000038 foo(){}
39//CHECK: @"\01??0foo@@QAE@XZ"
40
41 ~foo(){}
42//CHECK: @"\01??1foo@@QAE@XZ"
43
44 foo(int i){}
45//CHECK: @"\01??0foo@@QAE@H@Z"
46
47 foo(char *q){}
48//CHECK: @"\01??0foo@@QAE@PAD@Z"
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000049
50 static foo* static_method() { return 0; }
51
Michael J. Spencer50118da2011-12-01 09:55:00 +000052}f,s1(1),s2((char*)0);
Charles Davisb021f8b2010-06-14 05:29:01 +000053
Richard Smithc0838d22012-06-08 00:37:04 +000054typedef foo (foo2);
55
Charles Davisc62458f2010-06-18 07:51:00 +000056struct bar {
57 static int g;
58};
59
60union baz {
61 int a;
62 char b;
63 double c;
64};
65
66enum quux {
67 qone,
68 qtwo,
69 qthree
70};
71
Timur Iskhodzhanovdf438042012-06-27 01:38:25 +000072foo bar() { return foo(); }
73//CHECK: @"\01?bar@@YA?AVfoo@@XZ"
74
75int foo::operator+(int a) {
76//CHECK: @"\01??Hfoo@@QAEHH@Z"
77
78 foo::static_method();
79//CHECK: @"\01?static_method@foo@@SAPAV1@XZ"
80 bar();
81 return a;
82}
Charles Davis21e2a7e2010-06-17 06:47:31 +000083
Charles Davisb021f8b2010-06-14 05:29:01 +000084const short foo::d = 0;
85volatile long foo::e;
86const volatile char foo::f = 'C';
87
Charles Davisc62458f2010-06-18 07:51:00 +000088int bar::g;
89
Charles Davis3a0d41d2010-06-26 03:50:05 +000090extern int * const h = &a;
91
Charles Davis0b8fe8c2010-06-30 08:09:57 +000092int i[10][20];
93
Charles Davis1139da12010-07-03 05:53:41 +000094int (__stdcall *j)(signed char, unsigned char);
95
Richard Smithc0838d22012-06-08 00:37:04 +000096const volatile char foo2::*k;
Charles Daviscd712cb2010-07-03 08:01:32 +000097
Richard Smithc0838d22012-06-08 00:37:04 +000098int (foo2::*l)(int);
Charles Daviscd712cb2010-07-03 08:01:32 +000099
Charles Davis65161d12010-06-16 05:33:16 +0000100// Static functions are mangled, too.
101// Also make sure calling conventions, arglists, and throw specs work.
102static void __stdcall alpha(float a, double b) throw() {}
103bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
Charles Davis3a0d41d2010-06-26 03:50:05 +0000104// CHECK: @"\01?beta@@YI_N_J_W@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000105 alpha(0.f, 0.0);
106 return false;
107}
108
Charles Davis3a0d41d2010-06-26 03:50:05 +0000109// CHECK: @"\01?alpha@@YGXMN@Z"
Charles Davis65161d12010-06-16 05:33:16 +0000110
Charles Davisc62458f2010-06-18 07:51:00 +0000111// Make sure tag-type mangling works.
112void gamma(class foo, struct bar, union baz, enum quux) {}
113// CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
114
Charles Davis3a0d41d2010-06-26 03:50:05 +0000115// Make sure pointer/reference-type mangling works.
116void delta(int * const a, const long &) {}
117// CHECK: @"\01?delta@@YAXQAHABJ@Z"
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000118
Charles Davis4d254832010-07-03 16:56:59 +0000119// Array mangling.
Charles Davis0b8fe8c2010-06-30 08:09:57 +0000120void epsilon(int a[][10][20]) {}
Charles Davis08778262010-07-03 08:15:16 +0000121// CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000122
Timur Iskhodzhanovbae11d82012-07-26 13:41:30 +0000123void zeta(int (*)(int, int)) {}
124// CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z"
125
126// Blocks mangling (Clang extension). A block should be mangled slightly
127// differently from a similar function pointer.
128void eta(int (^)(int, int)) {}
129// CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z"
Charles Davis4d254832010-07-03 16:56:59 +0000130
John McCall3a8ac072012-05-01 02:33:44 +0000131void operator_new_delete() {
132 char *ptr = new char;
133// CHECK: @"\01??2@YAPAXI@Z"
134
135 delete ptr;
136// CHECK: @"\01??3@YAXPAX@Z"
137
138 char *array = new char[42];
139// CHECK: @"\01??_U@YAPAXI@Z"
140
John McCalle2b45e22012-05-01 05:23:51 +0000141 delete [] array;
142// CHECK: @"\01??_V@YAXPAX@Z"
John McCall3a8ac072012-05-01 02:33:44 +0000143}
Richard Smithbd1d18e2012-06-04 22:46:59 +0000144
145// PR13022
146void (redundant_parens)();
147void redundant_parens_use() { redundant_parens(); }
148// CHECK: @"\01?redundant_parens@@YAXXZ"
Richard Smithc0838d22012-06-08 00:37:04 +0000149
Timur Iskhodzhanova5427442012-07-23 09:32:54 +0000150// PR13182, PR13047
Richard Smithc0838d22012-06-08 00:37:04 +0000151typedef double RGB[3];
152RGB color1;
153extern const RGB color2 = {};
Timur Iskhodzhanova5427442012-07-23 09:32:54 +0000154extern RGB const color3[5] = {};
155extern RGB const ((color4)[5]) = {};
Richard Smith06e767d2012-06-21 02:52:27 +0000156
157// PR12603
158enum E {};
159// CHECK: "\01?fooE@@YA?AW4E@@XZ"
160E fooE() { return E(); }
161
162class X {};
163// CHECK: "\01?fooX@@YA?AVX@@XZ"
164X fooX() { return X(); }