1 // RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | 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@@AEHH@ZA" 15 // CHECK: @"\01?color1@@3PANA" 16 17 // FIXME: The following three tests currently fail, see PR13182. 18 // Replace "CHECK-NOT" with "CHECK" when it is fixed. 19 // CHECK-NOT: @"\01?color2@@3QBNB" 20 // CHECK-NOT: @"\01?color3@@3QAY02$$CBNA" 21 // CHECK-NOT: @"\01?color4@@3QAY02$$CBNA" 22 23 int a; 24 25 namespace N { int b; } 26 27 static int c; 28 int _c(void) {return c;} 29 // CHECK: @"\01?_c@@YAHXZ" 30 31 class foo { 32 static const short d; 33 protected: 34 static volatile long e; 35 public: 36 static const volatile char f; 37 int operator+(int a); 38 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" 49 50 static foo* static_method() { return 0; } 51 52 }f,s1(1),s2((char*)0); 53 54 typedef foo (foo2); 55 56 struct bar { 57 static int g; 58 }; 59 60 union baz { 61 int a; 62 char b; 63 double c; 64 }; 65 66 enum quux { 67 qone, 68 qtwo, 69 qthree 70 }; 71 72 foo bar() { return foo(); } 73 //CHECK: @"\01?bar@@YA?AVfoo@@XZ" 74 75 int 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 } 83 84 const short foo::d = 0; 85 volatile long foo::e; 86 const volatile char foo::f = 'C'; 87 88 int bar::g; 89 90 extern int * const h = &a; 91 92 int i[10][20]; 93 94 int (__stdcall *j)(signed char, unsigned char); 95 96 const volatile char foo2::*k; 97 98 int (foo2::*l)(int); 99 100 // Static functions are mangled, too. 101 // Also make sure calling conventions, arglists, and throw specs work. 102 static void __stdcall alpha(float a, double b) throw() {} 103 bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) { 104 // CHECK: @"\01?beta@@YI_N_J_W@Z" 105 alpha(0.f, 0.0); 106 return false; 107 } 108 109 // CHECK: @"\01?alpha@@YGXMN@Z" 110 111 // Make sure tag-type mangling works. 112 void gamma(class foo, struct bar, union baz, enum quux) {} 113 // CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z" 114 115 // Make sure pointer/reference-type mangling works. 116 void delta(int * const a, const long &) {} 117 // CHECK: @"\01?delta@@YAXQAHABJ@Z" 118 119 // Array mangling. 120 void epsilon(int a[][10][20]) {} 121 // CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z" 122 123 void 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. 128 void eta(int (^)(int, int)) {} 129 // CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z" 130 131 void 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 141 delete [] array; 142 // CHECK: @"\01??_V@YAXPAX@Z" 143 } 144 145 // PR13022 146 void (redundant_parens)(); 147 void redundant_parens_use() { redundant_parens(); } 148 // CHECK: @"\01?redundant_parens@@YAXXZ" 149 150 // PR13182, PR13047 151 typedef double RGB[3]; 152 RGB color1; 153 extern const RGB color2 = {}; 154 extern RGB const color3[5] = {}; 155 extern RGB const ((color4)[5]) = {}; 156 157 // PR12603 158 enum E {}; 159 // CHECK: "\01?fooE@@YA?AW4E@@XZ" 160 E fooE() { return E(); } 161 162 class X {}; 163 // CHECK: "\01?fooX@@YA?AVX@@XZ" 164 X fooX() { return X(); } 165