1 // RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=19.00 | FileCheck %s --check-prefix=CHECK --check-prefix=MSVC2015 2 // RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -fms-compatibility-version=18.00 | FileCheck %s --check-prefix=CHECK --check-prefix=MSVC2013 3 4 namespace FTypeWithQuals { 5 template <typename T> 6 struct S {}; 7 8 using A = int () const; 9 S<A> a; 10 // CHECK-DAG: @"\01?a@FTypeWithQuals@@3U?$S@$$A8@@BAHXZ@1@A" 11 12 using B = int () volatile; 13 S<B> b; 14 // CHECK-DAG: @"\01?b@FTypeWithQuals@@3U?$S@$$A8@@CAHXZ@1@A" 15 16 using C = int () __restrict; 17 S<C> c; 18 // CHECK-DAG: @"\01?c@FTypeWithQuals@@3U?$S@$$A8@@IAAHXZ@1@A" 19 20 using D = int () const &; 21 S<D> d; 22 // CHECK-DAG: @"\01?d@FTypeWithQuals@@3U?$S@$$A8@@GBAHXZ@1@A" 23 24 using E = int () volatile &; 25 S<E> e; 26 // CHECK-DAG: @"\01?e@FTypeWithQuals@@3U?$S@$$A8@@GCAHXZ@1@A" 27 28 using F = int () __restrict &; 29 S<F> f; 30 // CHECK-DAG: @"\01?f@FTypeWithQuals@@3U?$S@$$A8@@IGAAHXZ@1@A" 31 32 using G = int () const &&; 33 S<G> g; 34 // CHECK-DAG: @"\01?g@FTypeWithQuals@@3U?$S@$$A8@@HBAHXZ@1@A" 35 36 using H = int () volatile &&; 37 S<H> h; 38 // CHECK-DAG: @"\01?h@FTypeWithQuals@@3U?$S@$$A8@@HCAHXZ@1@A" 39 40 using I = int () __restrict &&; 41 S<I> i; 42 // CHECK-DAG: @"\01?i@FTypeWithQuals@@3U?$S@$$A8@@IHAAHXZ@1@A" 43 44 using J = int (); 45 S<J> j; 46 // CHECK-DAG: @"\01?j@FTypeWithQuals@@3U?$S@$$A6AHXZ@1@A" 47 48 using K = int () &; 49 S<K> k; 50 // CHECK-DAG: @"\01?k@FTypeWithQuals@@3U?$S@$$A8@@GAAHXZ@1@A" 51 52 using L = int () &&; 53 S<L> l; 54 // CHECK-DAG: @"\01?l@FTypeWithQuals@@3U?$S@$$A8@@HAAHXZ@1@A" 55 } 56 57 // CHECK: "\01?DeducedType@@3HA" 58 auto DeducedType = 30; 59 60 // CHECK-DAG: @"\01?Char16Var@@3_SA" 61 char16_t Char16Var; 62 63 // CHECK-DAG: @"\01?Char32Var@@3_UA" 64 char32_t Char32Var; 65 66 // CHECK: "\01?LRef@@YAXAAH@Z" LRef(int & a)67void LRef(int& a) { } 68 69 // CHECK: "\01?RRef@@YAH$$QAH@Z" RRef(int && a)70int RRef(int&& a) { return a; } 71 72 // CHECK: "\01?Null@@YAX$$T@Z" 73 namespace std { typedef decltype(__nullptr) nullptr_t; } Null(std::nullptr_t)74void Null(std::nullptr_t) {} 75 76 namespace EnumMangling { 77 extern enum Enum01 { } Enum; 78 extern enum Enum02 : bool { } BoolEnum; 79 extern enum Enum03 : char { } CharEnum; 80 extern enum Enum04 : signed char { } SCharEnum; 81 extern enum Enum05 : unsigned char { } UCharEnum; 82 extern enum Enum06 : short { } SShortEnum; 83 extern enum Enum07 : unsigned short { } UShortEnum; 84 extern enum Enum08 : int { } SIntEnum; 85 extern enum Enum09 : unsigned int { } UIntEnum; 86 extern enum Enum10 : long { } SLongEnum; 87 extern enum Enum11 : unsigned long { } ULongEnum; 88 extern enum Enum12 : long long { } SLongLongEnum; 89 extern enum Enum13 : unsigned long long { } ULongLongEnum; 90 // CHECK-DAG: @"\01?Enum@EnumMangling@@3W4Enum01@1@A" 91 // CHECK-DAG: @"\01?BoolEnum@EnumMangling@@3W4Enum02@1@A 92 // CHECK-DAG: @"\01?CharEnum@EnumMangling@@3W4Enum03@1@A 93 // CHECK-DAG: @"\01?SCharEnum@EnumMangling@@3W4Enum04@1@A 94 // CHECK-DAG: @"\01?UCharEnum@EnumMangling@@3W4Enum05@1@A 95 // CHECK-DAG: @"\01?SShortEnum@EnumMangling@@3W4Enum06@1@A" 96 // CHECK-DAG: @"\01?UShortEnum@EnumMangling@@3W4Enum07@1@A" 97 // CHECK-DAG: @"\01?SIntEnum@EnumMangling@@3W4Enum08@1@A" 98 // CHECK-DAG: @"\01?UIntEnum@EnumMangling@@3W4Enum09@1@A" 99 // CHECK-DAG: @"\01?SLongEnum@EnumMangling@@3W4Enum10@1@A" 100 // CHECK-DAG: @"\01?ULongEnum@EnumMangling@@3W4Enum11@1@A" 101 // CHECK-DAG: @"\01?SLongLongEnum@EnumMangling@@3W4Enum12@1@A" 102 // CHECK-DAG: @"\01?ULongLongEnum@EnumMangling@@3W4Enum13@1@A" UseEnum()103 decltype(Enum) *UseEnum() { return &Enum; } UseBoolEnum()104 decltype(BoolEnum) *UseBoolEnum() { return &BoolEnum; } UseCharEnum()105 decltype(CharEnum) *UseCharEnum() { return &CharEnum; } UseSCharEnum()106 decltype(SCharEnum) *UseSCharEnum() { return &SCharEnum; } UseUCharEnum()107 decltype(UCharEnum) *UseUCharEnum() { return &UCharEnum; } UseSShortEnum()108 decltype(SShortEnum) *UseSShortEnum() { return &SShortEnum; } UseUShortEnum()109 decltype(UShortEnum) *UseUShortEnum() { return &UShortEnum; } UseSIntEnum()110 decltype(SIntEnum) *UseSIntEnum() { return &SIntEnum; } UseUIntEnum()111 decltype(UIntEnum) *UseUIntEnum() { return &UIntEnum; } UseSLongEnum()112 decltype(SLongEnum) *UseSLongEnum() { return &SLongEnum; } UseULongEnum()113 decltype(ULongEnum) *UseULongEnum() { return &ULongEnum; } UseSLongLongEnum()114 decltype(SLongLongEnum) *UseSLongLongEnum() { return &SLongLongEnum; } UseULongLongEnum()115 decltype(ULongLongEnum) *UseULongLongEnum() { return &ULongLongEnum; } 116 extern enum class EnumClass01 { } EnumClass; 117 extern enum class EnumClass02 : bool { } BoolEnumClass; 118 extern enum class EnumClass03 : char { } CharEnumClass; 119 extern enum class EnumClass04 : signed char { } SCharEnumClass; 120 extern enum class EnumClass05 : unsigned char { } UCharEnumClass; 121 extern enum class EnumClass06 : short { } SShortEnumClass; 122 extern enum class EnumClass07 : unsigned short { } UShortEnumClass; 123 extern enum class EnumClass08 : int { } SIntEnumClass; 124 extern enum class EnumClass09 : unsigned int { } UIntEnumClass; 125 extern enum class EnumClass10 : long { } SLongEnumClass; 126 extern enum class EnumClass11 : unsigned long { } ULongEnumClass; 127 extern enum class EnumClass12 : long long { } SLongLongEnumClass; 128 extern enum class EnumClass13 : unsigned long long { } ULongLongEnumClass; 129 // CHECK-DAG: @"\01?EnumClass@EnumMangling@@3W4EnumClass01@1@A" 130 // CHECK-DAG: @"\01?BoolEnumClass@EnumMangling@@3W4EnumClass02@1@A 131 // CHECK-DAG: @"\01?CharEnumClass@EnumMangling@@3W4EnumClass03@1@A 132 // CHECK-DAG: @"\01?SCharEnumClass@EnumMangling@@3W4EnumClass04@1@A 133 // CHECK-DAG: @"\01?UCharEnumClass@EnumMangling@@3W4EnumClass05@1@A 134 // CHECK-DAG: @"\01?SShortEnumClass@EnumMangling@@3W4EnumClass06@1@A" 135 // CHECK-DAG: @"\01?UShortEnumClass@EnumMangling@@3W4EnumClass07@1@A" 136 // CHECK-DAG: @"\01?SIntEnumClass@EnumMangling@@3W4EnumClass08@1@A" 137 // CHECK-DAG: @"\01?UIntEnumClass@EnumMangling@@3W4EnumClass09@1@A" 138 // CHECK-DAG: @"\01?SLongEnumClass@EnumMangling@@3W4EnumClass10@1@A" 139 // CHECK-DAG: @"\01?ULongEnumClass@EnumMangling@@3W4EnumClass11@1@A" 140 // CHECK-DAG: @"\01?SLongLongEnumClass@EnumMangling@@3W4EnumClass12@1@A" 141 // CHECK-DAG: @"\01?ULongLongEnumClass@EnumMangling@@3W4EnumClass13@1@A" UseEnumClass()142 decltype(EnumClass) *UseEnumClass() { return &EnumClass; } UseBoolEnumClass()143 decltype(BoolEnumClass) *UseBoolEnumClass() { return &BoolEnumClass; } UseCharEnumClass()144 decltype(CharEnumClass) *UseCharEnumClass() { return &CharEnumClass; } UseSCharEnumClass()145 decltype(SCharEnumClass) *UseSCharEnumClass() { return &SCharEnumClass; } UseUCharEnumClass()146 decltype(UCharEnumClass) *UseUCharEnumClass() { return &UCharEnumClass; } UseSShortEnumClass()147 decltype(SShortEnumClass) *UseSShortEnumClass() { return &SShortEnumClass; } UseUShortEnumClass()148 decltype(UShortEnumClass) *UseUShortEnumClass() { return &UShortEnumClass; } UseSIntEnumClass()149 decltype(SIntEnumClass) *UseSIntEnumClass() { return &SIntEnumClass; } UseUIntEnumClass()150 decltype(UIntEnumClass) *UseUIntEnumClass() { return &UIntEnumClass; } UseSLongEnumClass()151 decltype(SLongEnumClass) *UseSLongEnumClass() { return &SLongEnumClass; } UseULongEnumClass()152 decltype(ULongEnumClass) *UseULongEnumClass() { return &ULongEnumClass; } UseSLongLongEnumClass()153 decltype(SLongLongEnumClass) *UseSLongLongEnumClass() { return &SLongLongEnumClass; } UseULongLongEnumClass()154 decltype(ULongLongEnumClass) *UseULongLongEnumClass() { return &ULongLongEnumClass; } 155 } 156 157 namespace PR18022 { 158 159 struct { } a; fun(decltype(a) x,decltype(a) )160decltype(a) fun(decltype(a) x, decltype(a)) { return x; } 161 // CHECK-DAG: @"\01?fun@PR18022@@YA?AU<unnamed-type-a>@1@U21@0@Z" 162 163 } 164 define_lambda()165inline int define_lambda() { 166 static auto lambda = [] { static int local; ++local; return local; }; 167 // First, we have the static local variable of type "<lambda_1>" inside of 168 // "define_lambda". 169 // CHECK-DAG: @"\01?lambda@?1??define_lambda@@YAHXZ@4V<lambda_1>@?1@YAHXZ@A" 170 // Next, we have the "operator()" for "<lambda_1>" which is inside of 171 // "define_lambda". 172 // CHECK-DAG: @"\01??R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ" 173 // Finally, we have the local which is inside of "<lambda_1>" which is inside of 174 // "define_lambda". Hooray. 175 // MSVC2013-DAG: @"\01?local@?2???R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ@4HA" 176 // MSVC2015-DAG: @"\01?local@?1???R<lambda_1>@?define_lambda@@YAHXZ@QBEHXZ@4HA" 177 return lambda(); 178 } 179 180 template <typename T> use_lambda_arg(T)181void use_lambda_arg(T) {} 182 call_with_lambda_arg1()183inline void call_with_lambda_arg1() { 184 use_lambda_arg([]{}); 185 // CHECK-DAG: @"\01??$use_lambda_arg@V<lambda_1>@?call_with_lambda_arg1@@YAXXZ@@@YAXV<lambda_1>@?call_with_lambda_arg1@@YAXXZ@@Z" 186 } 187 call_with_lambda_arg2()188inline void call_with_lambda_arg2() { 189 use_lambda_arg([]{}); 190 // CHECK-DAG: @"\01??$use_lambda_arg@V<lambda_1>@?call_with_lambda_arg2@@YAXXZ@@@YAXV<lambda_1>@?call_with_lambda_arg2@@YAXXZ@@Z" 191 } 192 call_lambda()193int call_lambda() { 194 call_with_lambda_arg1(); 195 call_with_lambda_arg2(); 196 return define_lambda(); 197 } 198 199 namespace PR19361 { 200 struct A { 201 void foo() __restrict &; 202 void foo() __restrict &&; 203 }; foo()204void A::foo() __restrict & {} 205 // CHECK-DAG: @"\01?foo@A@PR19361@@QIGAEXXZ" foo()206void A::foo() __restrict && {} 207 // CHECK-DAG: @"\01?foo@A@PR19361@@QIHAEXXZ" 208 } 209 operator ""_deg(long double)210int operator"" _deg(long double) { return 0; } 211 // CHECK-DAG: @"\01??__K_deg@@YAHO@Z" 212 213 template <char...> templ_fun_with_pack()214void templ_fun_with_pack() {} 215 216 template void templ_fun_with_pack<>(); 217 // CHECK-DAG: @"\01??$templ_fun_with_pack@$S@@YAXXZ" 218 219 template <typename...> templ_fun_with_ty_pack()220void templ_fun_with_ty_pack() {} 221 222 template void templ_fun_with_ty_pack<>(); 223 // MSVC2013-DAG: @"\01??$templ_fun_with_ty_pack@$$$V@@YAXXZ" 224 // MSVC2015-DAG: @"\01??$templ_fun_with_ty_pack@$$V@@YAXXZ" 225 226 template <template <class> class...> templ_fun_with_templ_templ_pack()227void templ_fun_with_templ_templ_pack() {} 228 229 template void templ_fun_with_templ_templ_pack<>(); 230 // MSVC2013-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$$V@@YAXXZ" 231 // MSVC2015-DAG: @"\01??$templ_fun_with_templ_templ_pack@$$V@@YAXXZ" 232 233 namespace PR20047 { 234 template <typename T> 235 struct A {}; 236 237 template <typename T> 238 using AliasA = A<T>; 239 240 template <template <typename> class> f()241void f() {} 242 243 template void f<AliasA>(); 244 // CHECK-DAG: @"\01??$f@$$YAliasA@PR20047@@@PR20047@@YAXXZ" 245 } 246 247 namespace UnnamedType { 248 struct A { 249 struct {} *TD; 250 }; 251 f(decltype(* A::TD) )252void f(decltype(*A::TD)) {} 253 // CHECK-DAG: @"\01?f@UnnamedType@@YAXAAU<unnamed-type-TD>@A@1@@Z" 254 255 template <typename T> 256 struct B { 257 enum { 258 } *e; 259 }; 260 f(decltype(B<int>::e) )261void f(decltype(B<int>::e)) {} 262 // CHECK-DAG: @"\01?f@UnnamedType@@YAXPAW4<unnamed-type-e>@?$B@H@1@@Z 263 } 264 265 namespace PR24651 { 266 template <typename T> f(T)267void f(T) {} 268 g()269void g() { 270 enum {} E; 271 f(E); 272 { 273 enum {} E; 274 f(E); 275 } 276 } 277 // CHECK-DAG: @"\01??$f@W4<unnamed-type-E>@?1??g@PR24651@@YAXXZ@@PR24651@@YAXW4<unnamed-type-E>@?1??g@0@YAXXZ@@Z" 278 // CHECK-DAG: @"\01??$f@W4<unnamed-type-E>@?2??g@PR24651@@YAXXZ@@PR24651@@YAXW4<unnamed-type-E>@?2??g@0@YAXXZ@@Z" 279 } 280 281 namespace PR18204 { 282 template <typename T> 283 int f(T *); 284 static union { 285 int n = f(this); 286 }; 287 // CHECK-DAG: @"\01??$f@T<unnamed-type-$S1>@PR18204@@@PR18204@@YAHPAT<unnamed-type-$S1>@0@@Z" 288 } 289