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