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 4namespace FTypeWithQuals { 5template <typename T> 6struct S {}; 7 8using A = int () const; 9S<A> a; 10// CHECK-DAG: @"\01?a@FTypeWithQuals@@3U?$S@$$A8@@BAHXZ@1@A" 11 12using B = int () volatile; 13S<B> b; 14// CHECK-DAG: @"\01?b@FTypeWithQuals@@3U?$S@$$A8@@CAHXZ@1@A" 15 16using C = int () __restrict; 17S<C> c; 18// CHECK-DAG: @"\01?c@FTypeWithQuals@@3U?$S@$$A8@@IAAHXZ@1@A" 19 20using D = int () const &; 21S<D> d; 22// CHECK-DAG: @"\01?d@FTypeWithQuals@@3U?$S@$$A8@@GBAHXZ@1@A" 23 24using E = int () volatile &; 25S<E> e; 26// CHECK-DAG: @"\01?e@FTypeWithQuals@@3U?$S@$$A8@@GCAHXZ@1@A" 27 28using F = int () __restrict &; 29S<F> f; 30// CHECK-DAG: @"\01?f@FTypeWithQuals@@3U?$S@$$A8@@IGAAHXZ@1@A" 31 32using G = int () const &&; 33S<G> g; 34// CHECK-DAG: @"\01?g@FTypeWithQuals@@3U?$S@$$A8@@HBAHXZ@1@A" 35 36using H = int () volatile &&; 37S<H> h; 38// CHECK-DAG: @"\01?h@FTypeWithQuals@@3U?$S@$$A8@@HCAHXZ@1@A" 39 40using I = int () __restrict &&; 41S<I> i; 42// CHECK-DAG: @"\01?i@FTypeWithQuals@@3U?$S@$$A8@@IHAAHXZ@1@A" 43 44using J = int (); 45S<J> j; 46// CHECK-DAG: @"\01?j@FTypeWithQuals@@3U?$S@$$A6AHXZ@1@A" 47 48using K = int () &; 49S<K> k; 50// CHECK-DAG: @"\01?k@FTypeWithQuals@@3U?$S@$$A8@@GAAHXZ@1@A" 51 52using L = int () &&; 53S<L> l; 54// CHECK-DAG: @"\01?l@FTypeWithQuals@@3U?$S@$$A8@@HAAHXZ@1@A" 55} 56 57// CHECK: "\01?DeducedType@@3HA" 58auto DeducedType = 30; 59 60// CHECK-DAG: @"\01?Char16Var@@3_SA" 61char16_t Char16Var; 62 63// CHECK-DAG: @"\01?Char32Var@@3_UA" 64char32_t Char32Var; 65 66// CHECK: "\01?LRef@@YAXAAH@Z" 67void LRef(int& a) { } 68 69// CHECK: "\01?RRef@@YAH$$QAH@Z" 70int RRef(int&& a) { return a; } 71 72// CHECK: "\01?Null@@YAX$$T@Z" 73namespace std { typedef decltype(__nullptr) nullptr_t; } 74void Null(std::nullptr_t) {} 75 76namespace 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" 103 decltype(Enum) *UseEnum() { return &Enum; } 104 decltype(BoolEnum) *UseBoolEnum() { return &BoolEnum; } 105 decltype(CharEnum) *UseCharEnum() { return &CharEnum; } 106 decltype(SCharEnum) *UseSCharEnum() { return &SCharEnum; } 107 decltype(UCharEnum) *UseUCharEnum() { return &UCharEnum; } 108 decltype(SShortEnum) *UseSShortEnum() { return &SShortEnum; } 109 decltype(UShortEnum) *UseUShortEnum() { return &UShortEnum; } 110 decltype(SIntEnum) *UseSIntEnum() { return &SIntEnum; } 111 decltype(UIntEnum) *UseUIntEnum() { return &UIntEnum; } 112 decltype(SLongEnum) *UseSLongEnum() { return &SLongEnum; } 113 decltype(ULongEnum) *UseULongEnum() { return &ULongEnum; } 114 decltype(SLongLongEnum) *UseSLongLongEnum() { return &SLongLongEnum; } 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" 142 decltype(EnumClass) *UseEnumClass() { return &EnumClass; } 143 decltype(BoolEnumClass) *UseBoolEnumClass() { return &BoolEnumClass; } 144 decltype(CharEnumClass) *UseCharEnumClass() { return &CharEnumClass; } 145 decltype(SCharEnumClass) *UseSCharEnumClass() { return &SCharEnumClass; } 146 decltype(UCharEnumClass) *UseUCharEnumClass() { return &UCharEnumClass; } 147 decltype(SShortEnumClass) *UseSShortEnumClass() { return &SShortEnumClass; } 148 decltype(UShortEnumClass) *UseUShortEnumClass() { return &UShortEnumClass; } 149 decltype(SIntEnumClass) *UseSIntEnumClass() { return &SIntEnumClass; } 150 decltype(UIntEnumClass) *UseUIntEnumClass() { return &UIntEnumClass; } 151 decltype(SLongEnumClass) *UseSLongEnumClass() { return &SLongEnumClass; } 152 decltype(ULongEnumClass) *UseULongEnumClass() { return &ULongEnumClass; } 153 decltype(SLongLongEnumClass) *UseSLongLongEnumClass() { return &SLongLongEnumClass; } 154 decltype(ULongLongEnumClass) *UseULongLongEnumClass() { return &ULongLongEnumClass; } 155} 156 157namespace PR18022 { 158 159struct { } 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 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>@?0??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>@?0??define_lambda@@YAHXZ@QBE@XZ" 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>@?0??define_lambda@@YAHXZ@QBE@XZ@4HA" 176// MSVC2015-DAG: @"\01?local@?1???R<lambda_1>@?0??define_lambda@@YAHXZ@QBE@XZ@4HA" 177 return lambda(); 178} 179 180template <typename T> 181void use_lambda_arg(T) {} 182 183inline void call_with_lambda_arg1() { 184 use_lambda_arg([]{}); 185 // CHECK-DAG: @"\01??$use_lambda_arg@V<lambda_1>@?0??call_with_lambda_arg1@@YAXXZ@@@YAXV<lambda_1>@?0??call_with_lambda_arg1@@YAXXZ@@Z" 186} 187 188inline void call_with_lambda_arg2() { 189 use_lambda_arg([]{}); 190 // CHECK-DAG: @"\01??$use_lambda_arg@V<lambda_1>@?0??call_with_lambda_arg2@@YAXXZ@@@YAXV<lambda_1>@?0??call_with_lambda_arg2@@YAXXZ@@Z" 191} 192 193int call_lambda() { 194 call_with_lambda_arg1(); 195 call_with_lambda_arg2(); 196 return define_lambda(); 197} 198 199namespace PR19361 { 200struct A { 201 void foo() __restrict &; 202 void foo() __restrict &&; 203}; 204void A::foo() __restrict & {} 205// CHECK-DAG: @"\01?foo@A@PR19361@@QIGAEXXZ" 206void A::foo() __restrict && {} 207// CHECK-DAG: @"\01?foo@A@PR19361@@QIHAEXXZ" 208} 209 210int operator"" _deg(long double) { return 0; } 211// CHECK-DAG: @"\01??__K_deg@@YAHO@Z" 212 213template <char...> 214void templ_fun_with_pack() {} 215 216template void templ_fun_with_pack<>(); 217// CHECK-DAG: @"\01??$templ_fun_with_pack@$S@@YAXXZ" 218 219template <typename...> 220void templ_fun_with_ty_pack() {} 221 222template 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 226template <template <class> class...> 227void templ_fun_with_templ_templ_pack() {} 228 229template 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 233namespace PR20047 { 234template <typename T> 235struct A {}; 236 237template <typename T> 238using AliasA = A<T>; 239 240template <template <typename> class> 241void f() {} 242 243template void f<AliasA>(); 244// CHECK-DAG: @"\01??$f@$$YAliasA@PR20047@@@PR20047@@YAXXZ" 245} 246 247namespace UnnamedType { 248struct A { 249 struct {} *TD; 250}; 251 252void f(decltype(*A::TD)) {} 253// CHECK-DAG: @"\01?f@UnnamedType@@YAXAAU<unnamed-type-TD>@A@1@@Z" 254 255template <typename T> 256struct B { 257 enum { 258 } *e; 259}; 260 261void f(decltype(B<int>::e)) {} 262// CHECK-DAG: @"\01?f@UnnamedType@@YAXPAW4<unnamed-type-e>@?$B@H@1@@Z 263} 264 265namespace PR24651 { 266template <typename T> 267void f(T) {} 268 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 281namespace PR18204 { 282template <typename T> 283int f(T *); 284static 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 290int PR26105() { 291 auto add = [](int x) { return ([x](int y) { return x + y; }); }; 292 return add(3)(4); 293} 294// CHECK-DAG: @"\01??R<lambda_0>@?0??PR26105@@YAHXZ@QBE@H@Z" 295// CHECK-DAG: @"\01??R<lambda_1>@?0???R<lambda_0>@?0??PR26105@@YAHXZ@QBE@H@Z@QBE@H@Z" 296 297int __unaligned * unaligned_foo1() { return 0; } 298int __unaligned * __unaligned * unaligned_foo2() { return 0; } 299__unaligned int unaligned_foo3() { return 0; } 300void unaligned_foo4(int __unaligned *p1) {} 301void unaligned_foo5(int __unaligned * __restrict p1) {} 302template <typename T> T unaligned_foo6(T t) { return t; } 303void unaligned_foo7() { unaligned_foo6<int *>(0); unaligned_foo6<int __unaligned *>(0); } 304 305// CHECK-DAG: @"\01?unaligned_foo1@@YAPFAHXZ" 306// CHECK-DAG: @"\01?unaligned_foo2@@YAPFAPFAHXZ" 307// CHECK-DAG: @"\01?unaligned_foo3@@YAHXZ" 308// CHECK-DAG: @"\01?unaligned_foo4@@YAXPFAH@Z" 309// CHECK-DAG: @"\01?unaligned_foo5@@YAXPIFAH@Z" 310// CHECK-DAG: @"\01??$unaligned_foo6@PAH@@YAPAHPAH@Z" 311// CHECK-DAG: @"\01??$unaligned_foo6@PFAH@@YAPFAHPFAH@Z" 312 313// __unaligned qualifier for function types 314struct unaligned_foo8_S { 315 void unaligned_foo8() volatile __unaligned; 316}; 317void unaligned_foo8_S::unaligned_foo8() volatile __unaligned {} 318 319// CHECK-DAG: @"\01?unaligned_foo8@unaligned_foo8_S@@QFCEXXZ" 320 321