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