mangle-ms.cpp revision 08778269cfbf803fb216870060c60eb2adb25ef6
1// RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-apple-darwin10 | 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?h@@3QAHA"
11// CHECK: @"\01?i@@3PAY0BE@HA"
12// CHECK: @"\01?j@@3P6GHCE@ZA"
13// CHECK: @"\01?k@@3PTfoo@@DA"
14// CHECK: @"\01?l@@3P8foo@@AAHH@ZA"
15
16int a;
17
18namespace N { int b; }
19
20static int c;
21int _c(void) {return c;}
22// CHECK: @"\01?_c@@YAHXZ"
23
24class foo {
25  static const short d;
26protected:
27  static volatile long e;
28public:
29  static const volatile char f;
30  int operator+(int a);
31};
32
33struct bar {
34  static int g;
35};
36
37union baz {
38  int a;
39  char b;
40  double c;
41};
42
43enum quux {
44  qone,
45  qtwo,
46  qthree
47};
48
49// NOTE: The calling convention is supposed to be __thiscall by default,
50// but that needs to be fixed in Sema/AST.
51int foo::operator+(int a) {return a;}
52// CHECK: @"\01??Hfoo@@QAAHH@Z"
53
54const short foo::d = 0;
55volatile long foo::e;
56const volatile char foo::f = 'C';
57
58int bar::g;
59
60extern int * const h = &a;
61
62int i[10][20];
63
64int (__stdcall *j)(signed char, unsigned char);
65
66const volatile char foo::*k;
67
68int (foo::*l)(int);
69
70// Static functions are mangled, too.
71// Also make sure calling conventions, arglists, and throw specs work.
72static void __stdcall alpha(float a, double b) throw() {}
73bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
74// CHECK: @"\01?beta@@YI_N_J_W@Z"
75  alpha(0.f, 0.0);
76  return false;
77}
78
79// CHECK: @"\01?alpha@@YGXMN@Z"
80
81// Make sure tag-type mangling works.
82void gamma(class foo, struct bar, union baz, enum quux) {}
83// CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
84
85// Make sure pointer/reference-type mangling works.
86void delta(int * const a, const long &) {}
87// CHECK: @"\01?delta@@YAXQAHABJ@Z"
88
89// Array mangling. (It should be mangled as a const pointer, but that needs
90// to be fixed in Sema.)
91void epsilon(int a[][10][20]) {}
92// CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
93