1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s 2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix=X64 %s 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc void foo(const unsigned int) {} 5*f4a2713aSLionel Sambuc // CHECK: "\01?foo@@YAXI@Z" 6*f4a2713aSLionel Sambuc // X64: "\01?foo@@YAXI@Z" 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc void foo(const double) {} 9*f4a2713aSLionel Sambuc // CHECK: "\01?foo@@YAXN@Z" 10*f4a2713aSLionel Sambuc // X64: "\01?foo@@YAXN@Z" 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc void bar(const volatile double) {} 13*f4a2713aSLionel Sambuc // CHECK: "\01?bar@@YAXN@Z" 14*f4a2713aSLionel Sambuc // X64: "\01?bar@@YAXN@Z" 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc void foo_pad(char * x) {} 17*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pad@@YAXPAD@Z" 18*f4a2713aSLionel Sambuc // X64: "\01?foo_pad@@YAXPEAD@Z" 19*f4a2713aSLionel Sambuc 20*f4a2713aSLionel Sambuc void foo_pbd(const char * x) {} 21*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pbd@@YAXPBD@Z" 22*f4a2713aSLionel Sambuc // X64: "\01?foo_pbd@@YAXPEBD@Z" 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc void foo_pcd(volatile char * x) {} 25*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pcd@@YAXPCD@Z" 26*f4a2713aSLionel Sambuc // X64: "\01?foo_pcd@@YAXPECD@Z" 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc void foo_qad(char * const x) {} 29*f4a2713aSLionel Sambuc // CHECK: "\01?foo_qad@@YAXQAD@Z" 30*f4a2713aSLionel Sambuc // X64: "\01?foo_qad@@YAXQEAD@Z" 31*f4a2713aSLionel Sambuc 32*f4a2713aSLionel Sambuc void foo_rad(char * volatile x) {} 33*f4a2713aSLionel Sambuc // CHECK: "\01?foo_rad@@YAXRAD@Z" 34*f4a2713aSLionel Sambuc // X64: "\01?foo_rad@@YAXREAD@Z" 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc void foo_sad(char * const volatile x) {} 37*f4a2713aSLionel Sambuc // CHECK: "\01?foo_sad@@YAXSAD@Z" 38*f4a2713aSLionel Sambuc // X64: "\01?foo_sad@@YAXSEAD@Z" 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc void foo_papad(char ** x) {} 41*f4a2713aSLionel Sambuc // CHECK: "\01?foo_papad@@YAXPAPAD@Z" 42*f4a2713aSLionel Sambuc // X64: "\01?foo_papad@@YAXPEAPEAD@Z" 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc void foo_papbd(char const ** x) {} 45*f4a2713aSLionel Sambuc // CHECK: "\01?foo_papbd@@YAXPAPBD@Z" 46*f4a2713aSLionel Sambuc // X64: "\01?foo_papbd@@YAXPEAPEBD@Z" 47*f4a2713aSLionel Sambuc 48*f4a2713aSLionel Sambuc void foo_papcd(char volatile ** x) {} 49*f4a2713aSLionel Sambuc // CHECK: "\01?foo_papcd@@YAXPAPCD@Z" 50*f4a2713aSLionel Sambuc // X64: "\01?foo_papcd@@YAXPEAPECD@Z" 51*f4a2713aSLionel Sambuc 52*f4a2713aSLionel Sambuc void foo_pbqad(char * const* x) {} 53*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pbqad@@YAXPBQAD@Z" 54*f4a2713aSLionel Sambuc // X64: "\01?foo_pbqad@@YAXPEBQEAD@Z" 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc void foo_pcrad(char * volatile* x) {} 57*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pcrad@@YAXPCRAD@Z" 58*f4a2713aSLionel Sambuc // X64: "\01?foo_pcrad@@YAXPECREAD@Z" 59*f4a2713aSLionel Sambuc 60*f4a2713aSLionel Sambuc void foo_qapad(char ** const x) {} 61*f4a2713aSLionel Sambuc // CHECK: "\01?foo_qapad@@YAXQAPAD@Z" 62*f4a2713aSLionel Sambuc // X64: "\01?foo_qapad@@YAXQEAPEAD@Z" 63*f4a2713aSLionel Sambuc 64*f4a2713aSLionel Sambuc void foo_rapad(char ** volatile x) {} 65*f4a2713aSLionel Sambuc // CHECK: "\01?foo_rapad@@YAXRAPAD@Z" 66*f4a2713aSLionel Sambuc // X64: "\01?foo_rapad@@YAXREAPEAD@Z" 67*f4a2713aSLionel Sambuc 68*f4a2713aSLionel Sambuc void foo_pbqbd(const char * const* x) {} 69*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pbqbd@@YAXPBQBD@Z" 70*f4a2713aSLionel Sambuc // X64: "\01?foo_pbqbd@@YAXPEBQEBD@Z" 71*f4a2713aSLionel Sambuc 72*f4a2713aSLionel Sambuc void foo_pbqcd(volatile char * const* x) {} 73*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pbqcd@@YAXPBQCD@Z" 74*f4a2713aSLionel Sambuc // X64: "\01?foo_pbqcd@@YAXPEBQECD@Z" 75*f4a2713aSLionel Sambuc 76*f4a2713aSLionel Sambuc void foo_pcrbd(const char * volatile* x) {} 77*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pcrbd@@YAXPCRBD@Z" 78*f4a2713aSLionel Sambuc // X64: "\01?foo_pcrbd@@YAXPECREBD@Z" 79*f4a2713aSLionel Sambuc 80*f4a2713aSLionel Sambuc void foo_pcrcd(volatile char * volatile* x) {} 81*f4a2713aSLionel Sambuc // CHECK: "\01?foo_pcrcd@@YAXPCRCD@Z" 82*f4a2713aSLionel Sambuc // X64: "\01?foo_pcrcd@@YAXPECRECD@Z" 83*f4a2713aSLionel Sambuc 84*f4a2713aSLionel Sambuc void foo_aad(char &x) {} 85*f4a2713aSLionel Sambuc // CHECK: "\01?foo_aad@@YAXAAD@Z" 86*f4a2713aSLionel Sambuc // X64: "\01?foo_aad@@YAXAEAD@Z" 87*f4a2713aSLionel Sambuc 88*f4a2713aSLionel Sambuc void foo_abd(const char &x) {} 89*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abd@@YAXABD@Z" 90*f4a2713aSLionel Sambuc // X64: "\01?foo_abd@@YAXAEBD@Z" 91*f4a2713aSLionel Sambuc 92*f4a2713aSLionel Sambuc void foo_aapad(char *&x) {} 93*f4a2713aSLionel Sambuc // CHECK: "\01?foo_aapad@@YAXAAPAD@Z" 94*f4a2713aSLionel Sambuc // X64: "\01?foo_aapad@@YAXAEAPEAD@Z" 95*f4a2713aSLionel Sambuc 96*f4a2713aSLionel Sambuc void foo_aapbd(const char *&x) {} 97*f4a2713aSLionel Sambuc // CHECK: "\01?foo_aapbd@@YAXAAPBD@Z" 98*f4a2713aSLionel Sambuc // X64: "\01?foo_aapbd@@YAXAEAPEBD@Z" 99*f4a2713aSLionel Sambuc 100*f4a2713aSLionel Sambuc void foo_abqad(char * const &x) {} 101*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abqad@@YAXABQAD@Z" 102*f4a2713aSLionel Sambuc // X64: "\01?foo_abqad@@YAXAEBQEAD@Z" 103*f4a2713aSLionel Sambuc 104*f4a2713aSLionel Sambuc void foo_abqbd(const char * const &x) {} 105*f4a2713aSLionel Sambuc // CHECK: "\01?foo_abqbd@@YAXABQBD@Z" 106*f4a2713aSLionel Sambuc // X64: "\01?foo_abqbd@@YAXAEBQEBD@Z" 107*f4a2713aSLionel Sambuc 108*f4a2713aSLionel Sambuc void foo_aay144h(int (&x)[5][5]) {} 109*f4a2713aSLionel Sambuc // CHECK: "\01?foo_aay144h@@YAXAAY144H@Z" 110*f4a2713aSLionel Sambuc // X64: "\01?foo_aay144h@@YAXAEAY144H@Z" 111*f4a2713aSLionel Sambuc 112*f4a2713aSLionel Sambuc void foo_aay144cbh(const int (&x)[5][5]) {} 113*f4a2713aSLionel Sambuc // CHECK: "\01?foo_aay144cbh@@YAXAAY144$$CBH@Z" 114*f4a2713aSLionel Sambuc // X64: "\01?foo_aay144cbh@@YAXAEAY144$$CBH@Z" 115*f4a2713aSLionel Sambuc 116*f4a2713aSLionel Sambuc void foo_qay144h(int (&&x)[5][5]) {} 117*f4a2713aSLionel Sambuc // CHECK: "\01?foo_qay144h@@YAX$$QAY144H@Z" 118*f4a2713aSLionel Sambuc // X64: "\01?foo_qay144h@@YAX$$QEAY144H@Z" 119*f4a2713aSLionel Sambuc 120*f4a2713aSLionel Sambuc void foo_qay144cbh(const int (&&x)[5][5]) {} 121*f4a2713aSLionel Sambuc // CHECK: "\01?foo_qay144cbh@@YAX$$QAY144$$CBH@Z" 122*f4a2713aSLionel Sambuc // X64: "\01?foo_qay144cbh@@YAX$$QEAY144$$CBH@Z" 123*f4a2713aSLionel Sambuc 124*f4a2713aSLionel Sambuc void foo_p6ahxz(int x()) {} 125*f4a2713aSLionel Sambuc // CHECK: "\01?foo_p6ahxz@@YAXP6AHXZ@Z" 126*f4a2713aSLionel Sambuc // X64: "\01?foo_p6ahxz@@YAXP6AHXZ@Z" 127*f4a2713aSLionel Sambuc 128*f4a2713aSLionel Sambuc void foo_a6ahxz(int (&x)()) {} 129*f4a2713aSLionel Sambuc // CHECK: "\01?foo_a6ahxz@@YAXA6AHXZ@Z" 130*f4a2713aSLionel Sambuc // X64: "\01?foo_a6ahxz@@YAXA6AHXZ@Z" 131*f4a2713aSLionel Sambuc 132*f4a2713aSLionel Sambuc void foo_q6ahxz(int (&&x)()) {} 133*f4a2713aSLionel Sambuc // CHECK: "\01?foo_q6ahxz@@YAX$$Q6AHXZ@Z" 134*f4a2713aSLionel Sambuc // X64: "\01?foo_q6ahxz@@YAX$$Q6AHXZ@Z" 135*f4a2713aSLionel Sambuc 136*f4a2713aSLionel Sambuc void foo_qay04h(int x[5][5]) {} 137*f4a2713aSLionel Sambuc // CHECK: "\01?foo_qay04h@@YAXQAY04H@Z" 138*f4a2713aSLionel Sambuc // X64: "\01?foo_qay04h@@YAXQEAY04H@Z" 139*f4a2713aSLionel Sambuc 140*f4a2713aSLionel Sambuc void foo_qay04cbh(const int x[5][5]) {} 141*f4a2713aSLionel Sambuc // CHECK: "\01?foo_qay04cbh@@YAXQAY04$$CBH@Z" 142*f4a2713aSLionel Sambuc // X64: "\01?foo_qay04cbh@@YAXQEAY04$$CBH@Z" 143*f4a2713aSLionel Sambuc 144*f4a2713aSLionel Sambuc typedef double Vector[3]; 145*f4a2713aSLionel Sambuc 146*f4a2713aSLionel Sambuc void foo(Vector*) {} 147*f4a2713aSLionel Sambuc // CHECK: "\01?foo@@YAXPAY02N@Z" 148*f4a2713aSLionel Sambuc // X64: "\01?foo@@YAXPEAY02N@Z" 149*f4a2713aSLionel Sambuc 150*f4a2713aSLionel Sambuc void foo(Vector) {} 151*f4a2713aSLionel Sambuc // CHECK: "\01?foo@@YAXQAN@Z" 152*f4a2713aSLionel Sambuc // X64: "\01?foo@@YAXQEAN@Z" 153*f4a2713aSLionel Sambuc 154*f4a2713aSLionel Sambuc void foo_const(const Vector) {} 155*f4a2713aSLionel Sambuc // CHECK: "\01?foo_const@@YAXQBN@Z" 156*f4a2713aSLionel Sambuc // X64: "\01?foo_const@@YAXQEBN@Z" 157*f4a2713aSLionel Sambuc 158*f4a2713aSLionel Sambuc void foo_volatile(volatile Vector) {} 159*f4a2713aSLionel Sambuc // CHECK: "\01?foo_volatile@@YAXQCN@Z" 160*f4a2713aSLionel Sambuc // X64: "\01?foo_volatile@@YAXQECN@Z" 161*f4a2713aSLionel Sambuc 162*f4a2713aSLionel Sambuc void foo(Vector*, const Vector, const double) {} 163*f4a2713aSLionel Sambuc // CHECK: "\01?foo@@YAXPAY02NQBNN@Z" 164*f4a2713aSLionel Sambuc // X64: "\01?foo@@YAXPEAY02NQEBNN@Z" 165*f4a2713aSLionel Sambuc 166*f4a2713aSLionel Sambuc typedef void (*ConstFunPtr)(int *const d); 167*f4a2713aSLionel Sambuc void foo_fnptrconst(ConstFunPtr f) { } 168*f4a2713aSLionel Sambuc // CHECK: "\01?foo_fnptrconst@@YAXP6AXQAH@Z@Z" 169*f4a2713aSLionel Sambuc // X64: "\01?foo_fnptrconst@@YAXP6AXQEAH@Z@Z" 170*f4a2713aSLionel Sambuc 171*f4a2713aSLionel Sambuc typedef void (*ArrayFunPtr)(int d[1]); 172*f4a2713aSLionel Sambuc void foo_fnptrarray(ArrayFunPtr f) { } 173*f4a2713aSLionel Sambuc // CHECK: "\01?foo_fnptrarray@@YAXP6AXQAH@Z@Z" 174*f4a2713aSLionel Sambuc // X64: "\01?foo_fnptrarray@@YAXP6AXQEAH@Z@Z" 175*f4a2713aSLionel Sambuc 176*f4a2713aSLionel Sambuc void foo_fnptrbackref1(ArrayFunPtr f1, ArrayFunPtr f2) { } 177*f4a2713aSLionel Sambuc // CHECK: "\01?foo_fnptrbackref1@@YAXP6AXQAH@Z1@Z" 178*f4a2713aSLionel Sambuc // X64: "\01?foo_fnptrbackref1@@YAXP6AXQEAH@Z1@Z" 179*f4a2713aSLionel Sambuc 180*f4a2713aSLionel Sambuc void foo_fnptrbackref2(ArrayFunPtr f1, ConstFunPtr f2) { } 181*f4a2713aSLionel Sambuc // CHECK: "\01?foo_fnptrbackref2@@YAXP6AXQAH@Z1@Z" 182*f4a2713aSLionel Sambuc // X64: "\01?foo_fnptrbackref2@@YAXP6AXQEAH@Z1@Z" 183*f4a2713aSLionel Sambuc 184*f4a2713aSLionel Sambuc typedef void (*NormalFunPtr)(int *d); 185*f4a2713aSLionel Sambuc void foo_fnptrbackref3(ArrayFunPtr f1, NormalFunPtr f2) { } 186*f4a2713aSLionel Sambuc // CHECK: "\01?foo_fnptrbackref3@@YAXP6AXQAH@Z1@Z" 187*f4a2713aSLionel Sambuc // X64: "\01?foo_fnptrbackref3@@YAXP6AXQEAH@Z1@Z" 188*f4a2713aSLionel Sambuc 189*f4a2713aSLionel Sambuc void foo_fnptrbackref4(NormalFunPtr f1, ArrayFunPtr f2) { } 190*f4a2713aSLionel Sambuc // CHECK: "\01?foo_fnptrbackref4@@YAXP6AXPAH@Z1@Z" 191*f4a2713aSLionel Sambuc // X64: "\01?foo_fnptrbackref4@@YAXP6AXPEAH@Z1@Z" 192*f4a2713aSLionel Sambuc 193*f4a2713aSLionel Sambuc ArrayFunPtr ret_fnptrarray() { return 0; } 194*f4a2713aSLionel Sambuc // CHECK: "\01?ret_fnptrarray@@YAP6AXQAH@ZXZ" 195*f4a2713aSLionel Sambuc // X64: "\01?ret_fnptrarray@@YAP6AXQEAH@ZXZ" 196*f4a2713aSLionel Sambuc 197*f4a2713aSLionel Sambuc // Test that we mangle the forward decl when we have a redeclaration with a 198*f4a2713aSLionel Sambuc // slightly different type. 199*f4a2713aSLionel Sambuc void mangle_fwd(char * const x); 200*f4a2713aSLionel Sambuc void mangle_fwd(char * x) {} 201*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_fwd@@YAXQAD@Z" 202*f4a2713aSLionel Sambuc // X64: "\01?mangle_fwd@@YAXQEAD@Z" 203*f4a2713aSLionel Sambuc 204*f4a2713aSLionel Sambuc void mangle_no_fwd(char * x) {} 205*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_no_fwd@@YAXPAD@Z" 206*f4a2713aSLionel Sambuc // X64: "\01?mangle_no_fwd@@YAXPEAD@Z" 207*f4a2713aSLionel Sambuc 208*f4a2713aSLionel Sambuc // The first argument gets mangled as-if it were written "int *const" 209*f4a2713aSLionel Sambuc // The second arg should not form a backref because it isn't qualified 210*f4a2713aSLionel Sambuc void mangle_no_backref0(int[], int *) {} 211*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_no_backref0@@YAXQAHPAH@Z" 212*f4a2713aSLionel Sambuc // X64: "\01?mangle_no_backref0@@YAXQEAHPEAH@Z" 213*f4a2713aSLionel Sambuc 214*f4a2713aSLionel Sambuc void mangle_no_backref1(int[], int *const) {} 215*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_no_backref1@@YAXQAHQAH@Z" 216*f4a2713aSLionel Sambuc // X64: "\01?mangle_no_backref1@@YAXQEAHQEAH@Z" 217*f4a2713aSLionel Sambuc 218*f4a2713aSLionel Sambuc typedef void fun_type(void); 219*f4a2713aSLionel Sambuc typedef void (*ptr_to_fun_type)(void); 220*f4a2713aSLionel Sambuc 221*f4a2713aSLionel Sambuc // Pointer to function types don't backref with function types 222*f4a2713aSLionel Sambuc void mangle_no_backref2(fun_type, ptr_to_fun_type) {} 223*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_no_backref2@@YAXP6AXXZP6AXXZ@Z" 224*f4a2713aSLionel Sambuc // X64: "\01?mangle_no_backref2@@YAXP6AXXZP6AXXZ@Z" 225*f4a2713aSLionel Sambuc 226*f4a2713aSLionel Sambuc void mangle_yes_backref0(int[], int []) {} 227*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_yes_backref0@@YAXQAH0@Z" 228*f4a2713aSLionel Sambuc // X64: "\01?mangle_yes_backref0@@YAXQEAH0@Z" 229*f4a2713aSLionel Sambuc 230*f4a2713aSLionel Sambuc void mangle_yes_backref1(int *const, int *const) {} 231*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_yes_backref1@@YAXQAH0@Z" 232*f4a2713aSLionel Sambuc // X64: "\01?mangle_yes_backref1@@YAXQEAH0@Z" 233*f4a2713aSLionel Sambuc 234*f4a2713aSLionel Sambuc void mangle_yes_backref2(fun_type *const[], ptr_to_fun_type const[]) {} 235*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_yes_backref2@@YAXQBQ6AXXZ0@Z" 236*f4a2713aSLionel Sambuc // X64: "\01?mangle_yes_backref2@@YAXQEBQ6AXXZ0@Z" 237*f4a2713aSLionel Sambuc 238*f4a2713aSLionel Sambuc void mangle_yes_backref3(ptr_to_fun_type *const, void (**const)(void)) {} 239*f4a2713aSLionel Sambuc // CHECK: "\01?mangle_yes_backref3@@YAXQAP6AXXZ0@Z" 240*f4a2713aSLionel Sambuc // X64: "\01?mangle_yes_backref3@@YAXQEAP6AXXZ0@Z" 241