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 // RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -triple=i386-pc-win32 -gcodeview -debug-info-kind=limited | FileCheck %s --check-prefix=DBG 4 5 namespace FTypeWithQuals { 6 template <typename T> 7 struct S {}; 8 9 using A = int () const; 10 S<A> a; 11 // CHECK-DAG: @"?a@FTypeWithQuals@@3U?$S@$$A8@@BAHXZ@1@A" 12 13 using B = int () volatile; 14 S<B> b; 15 // CHECK-DAG: @"?b@FTypeWithQuals@@3U?$S@$$A8@@CAHXZ@1@A" 16 17 using C = int () __restrict; 18 S<C> c; 19 // CHECK-DAG: @"?c@FTypeWithQuals@@3U?$S@$$A8@@IAAHXZ@1@A" 20 21 using D = int () const &; 22 S<D> d; 23 // CHECK-DAG: @"?d@FTypeWithQuals@@3U?$S@$$A8@@GBAHXZ@1@A" 24 25 using E = int () volatile &; 26 S<E> e; 27 // CHECK-DAG: @"?e@FTypeWithQuals@@3U?$S@$$A8@@GCAHXZ@1@A" 28 29 using F = int () __restrict &; 30 S<F> f; 31 // CHECK-DAG: @"?f@FTypeWithQuals@@3U?$S@$$A8@@IGAAHXZ@1@A" 32 33 using G = int () const &&; 34 S<G> g; 35 // CHECK-DAG: @"?g@FTypeWithQuals@@3U?$S@$$A8@@HBAHXZ@1@A" 36 37 using H = int () volatile &&; 38 S<H> h; 39 // CHECK-DAG: @"?h@FTypeWithQuals@@3U?$S@$$A8@@HCAHXZ@1@A" 40 41 using I = int () __restrict &&; 42 S<I> i; 43 // CHECK-DAG: @"?i@FTypeWithQuals@@3U?$S@$$A8@@IHAAHXZ@1@A" 44 45 using J = int (); 46 S<J> j; 47 // CHECK-DAG: @"?j@FTypeWithQuals@@3U?$S@$$A6AHXZ@1@A" 48 49 using K = int () &; 50 S<K> k; 51 // CHECK-DAG: @"?k@FTypeWithQuals@@3U?$S@$$A8@@GAAHXZ@1@A" 52 53 using L = int () &&; 54 S<L> l; 55 // CHECK-DAG: @"?l@FTypeWithQuals@@3U?$S@$$A8@@HAAHXZ@1@A" 56 } 57 58 // CHECK: "?DeducedType@@3HA" 59 auto DeducedType = 30; 60 61 // CHECK-DAG: @"?Char16Var@@3_SA" 62 char16_t Char16Var; 63 64 // CHECK-DAG: @"?Char32Var@@3_UA" 65 char32_t Char32Var; 66 67 // CHECK: "?LRef@@YAXAAH@Z" LRef(int & a)68void LRef(int& a) { } 69 70 // CHECK: "?RRef@@YAH$$QAH@Z" RRef(int && a)71int RRef(int&& a) { return a; } 72 73 // CHECK: "?Null@@YAX$$T@Z" 74 namespace std { typedef decltype(__nullptr) nullptr_t; } Null(std::nullptr_t)75void Null(std::nullptr_t) {} 76 77 namespace EnumMangling { 78 extern enum Enum01 { } Enum; 79 extern enum Enum02 : bool { } BoolEnum; 80 extern enum Enum03 : char { } CharEnum; 81 extern enum Enum04 : signed char { } SCharEnum; 82 extern enum Enum05 : unsigned char { } UCharEnum; 83 extern enum Enum06 : short { } SShortEnum; 84 extern enum Enum07 : unsigned short { } UShortEnum; 85 extern enum Enum08 : int { } SIntEnum; 86 extern enum Enum09 : unsigned int { } UIntEnum; 87 extern enum Enum10 : long { } SLongEnum; 88 extern enum Enum11 : unsigned long { } ULongEnum; 89 extern enum Enum12 : long long { } SLongLongEnum; 90 extern enum Enum13 : unsigned long long { } ULongLongEnum; 91 // CHECK-DAG: @"?Enum@EnumMangling@@3W4Enum01@1@A" 92 // CHECK-DAG: @"?BoolEnum@EnumMangling@@3W4Enum02@1@A 93 // CHECK-DAG: @"?CharEnum@EnumMangling@@3W4Enum03@1@A 94 // CHECK-DAG: @"?SCharEnum@EnumMangling@@3W4Enum04@1@A 95 // CHECK-DAG: @"?UCharEnum@EnumMangling@@3W4Enum05@1@A 96 // CHECK-DAG: @"?SShortEnum@EnumMangling@@3W4Enum06@1@A" 97 // CHECK-DAG: @"?UShortEnum@EnumMangling@@3W4Enum07@1@A" 98 // CHECK-DAG: @"?SIntEnum@EnumMangling@@3W4Enum08@1@A" 99 // CHECK-DAG: @"?UIntEnum@EnumMangling@@3W4Enum09@1@A" 100 // CHECK-DAG: @"?SLongEnum@EnumMangling@@3W4Enum10@1@A" 101 // CHECK-DAG: @"?ULongEnum@EnumMangling@@3W4Enum11@1@A" 102 // CHECK-DAG: @"?SLongLongEnum@EnumMangling@@3W4Enum12@1@A" 103 // CHECK-DAG: @"?ULongLongEnum@EnumMangling@@3W4Enum13@1@A" UseEnum()104 decltype(Enum) *UseEnum() { return &Enum; } UseBoolEnum()105 decltype(BoolEnum) *UseBoolEnum() { return &BoolEnum; } UseCharEnum()106 decltype(CharEnum) *UseCharEnum() { return &CharEnum; } UseSCharEnum()107 decltype(SCharEnum) *UseSCharEnum() { return &SCharEnum; } UseUCharEnum()108 decltype(UCharEnum) *UseUCharEnum() { return &UCharEnum; } UseSShortEnum()109 decltype(SShortEnum) *UseSShortEnum() { return &SShortEnum; } UseUShortEnum()110 decltype(UShortEnum) *UseUShortEnum() { return &UShortEnum; } UseSIntEnum()111 decltype(SIntEnum) *UseSIntEnum() { return &SIntEnum; } UseUIntEnum()112 decltype(UIntEnum) *UseUIntEnum() { return &UIntEnum; } UseSLongEnum()113 decltype(SLongEnum) *UseSLongEnum() { return &SLongEnum; } UseULongEnum()114 decltype(ULongEnum) *UseULongEnum() { return &ULongEnum; } UseSLongLongEnum()115 decltype(SLongLongEnum) *UseSLongLongEnum() { return &SLongLongEnum; } UseULongLongEnum()116 decltype(ULongLongEnum) *UseULongLongEnum() { return &ULongLongEnum; } 117 extern enum class EnumClass01 { } EnumClass; 118 extern enum class EnumClass02 : bool { } BoolEnumClass; 119 extern enum class EnumClass03 : char { } CharEnumClass; 120 extern enum class EnumClass04 : signed char { } SCharEnumClass; 121 extern enum class EnumClass05 : unsigned char { } UCharEnumClass; 122 extern enum class EnumClass06 : short { } SShortEnumClass; 123 extern enum class EnumClass07 : unsigned short { } UShortEnumClass; 124 extern enum class EnumClass08 : int { } SIntEnumClass; 125 extern enum class EnumClass09 : unsigned int { } UIntEnumClass; 126 extern enum class EnumClass10 : long { } SLongEnumClass; 127 extern enum class EnumClass11 : unsigned long { } ULongEnumClass; 128 extern enum class EnumClass12 : long long { } SLongLongEnumClass; 129 extern enum class EnumClass13 : unsigned long long { } ULongLongEnumClass; 130 // CHECK-DAG: @"?EnumClass@EnumMangling@@3W4EnumClass01@1@A" 131 // CHECK-DAG: @"?BoolEnumClass@EnumMangling@@3W4EnumClass02@1@A 132 // CHECK-DAG: @"?CharEnumClass@EnumMangling@@3W4EnumClass03@1@A 133 // CHECK-DAG: @"?SCharEnumClass@EnumMangling@@3W4EnumClass04@1@A 134 // CHECK-DAG: @"?UCharEnumClass@EnumMangling@@3W4EnumClass05@1@A 135 // CHECK-DAG: @"?SShortEnumClass@EnumMangling@@3W4EnumClass06@1@A" 136 // CHECK-DAG: @"?UShortEnumClass@EnumMangling@@3W4EnumClass07@1@A" 137 // CHECK-DAG: @"?SIntEnumClass@EnumMangling@@3W4EnumClass08@1@A" 138 // CHECK-DAG: @"?UIntEnumClass@EnumMangling@@3W4EnumClass09@1@A" 139 // CHECK-DAG: @"?SLongEnumClass@EnumMangling@@3W4EnumClass10@1@A" 140 // CHECK-DAG: @"?ULongEnumClass@EnumMangling@@3W4EnumClass11@1@A" 141 // CHECK-DAG: @"?SLongLongEnumClass@EnumMangling@@3W4EnumClass12@1@A" 142 // CHECK-DAG: @"?ULongLongEnumClass@EnumMangling@@3W4EnumClass13@1@A" UseEnumClass()143 decltype(EnumClass) *UseEnumClass() { return &EnumClass; } UseBoolEnumClass()144 decltype(BoolEnumClass) *UseBoolEnumClass() { return &BoolEnumClass; } UseCharEnumClass()145 decltype(CharEnumClass) *UseCharEnumClass() { return &CharEnumClass; } UseSCharEnumClass()146 decltype(SCharEnumClass) *UseSCharEnumClass() { return &SCharEnumClass; } UseUCharEnumClass()147 decltype(UCharEnumClass) *UseUCharEnumClass() { return &UCharEnumClass; } UseSShortEnumClass()148 decltype(SShortEnumClass) *UseSShortEnumClass() { return &SShortEnumClass; } UseUShortEnumClass()149 decltype(UShortEnumClass) *UseUShortEnumClass() { return &UShortEnumClass; } UseSIntEnumClass()150 decltype(SIntEnumClass) *UseSIntEnumClass() { return &SIntEnumClass; } UseUIntEnumClass()151 decltype(UIntEnumClass) *UseUIntEnumClass() { return &UIntEnumClass; } UseSLongEnumClass()152 decltype(SLongEnumClass) *UseSLongEnumClass() { return &SLongEnumClass; } UseULongEnumClass()153 decltype(ULongEnumClass) *UseULongEnumClass() { return &ULongEnumClass; } UseSLongLongEnumClass()154 decltype(SLongLongEnumClass) *UseSLongLongEnumClass() { return &SLongLongEnumClass; } UseULongLongEnumClass()155 decltype(ULongLongEnumClass) *UseULongLongEnumClass() { return &ULongLongEnumClass; } 156 } 157 158 namespace PR18022 { 159 160 struct { } a; fun(decltype(a) x,decltype(a) )161decltype(a) fun(decltype(a) x, decltype(a)) { return x; } 162 // CHECK-DAG: @"?fun@PR18022@@YA?AU<unnamed-type-a>@1@U21@0@Z" 163 use_fun()164void use_fun() { fun(a, a); } 165 166 } 167 define_lambda()168inline int define_lambda() { 169 static auto lambda = [] { static int local; ++local; return local; }; 170 // First, we have the static local variable of type "<lambda_1>" inside of 171 // "define_lambda". 172 // CHECK-DAG: @"?lambda@?1??define_lambda@@YAHXZ@4V<lambda_1>@?0??1@YAHXZ@A" 173 // Next, we have the "operator()" for "<lambda_1>" which is inside of 174 // "define_lambda". 175 // CHECK-DAG: @"??R<lambda_1>@?0??define_lambda@@YAHXZ@QBE@XZ" 176 // Finally, we have the local which is inside of "<lambda_1>" which is inside of 177 // "define_lambda". Hooray. 178 // MSVC2013-DAG: @"?local@?2???R<lambda_1>@?0??define_lambda@@YAHXZ@QBE@XZ@4HA" 179 // MSVC2015-DAG: @"?local@?1???R<lambda_1>@?0??define_lambda@@YAHXZ@QBE@XZ@4HA" 180 return lambda(); 181 } 182 183 template <typename T> use_lambda_arg(T)184void use_lambda_arg(T) {} 185 call_with_lambda_arg1()186inline void call_with_lambda_arg1() { 187 use_lambda_arg([]{}); 188 // CHECK-DAG: @"??$use_lambda_arg@V<lambda_1>@?0??call_with_lambda_arg1@@YAXXZ@@@YAXV<lambda_1>@?0??call_with_lambda_arg1@@YAXXZ@@Z" 189 } 190 call_with_lambda_arg2()191inline void call_with_lambda_arg2() { 192 use_lambda_arg([]{}); 193 // CHECK-DAG: @"??$use_lambda_arg@V<lambda_1>@?0??call_with_lambda_arg2@@YAXXZ@@@YAXV<lambda_1>@?0??call_with_lambda_arg2@@YAXXZ@@Z" 194 } 195 call_lambda()196int call_lambda() { 197 call_with_lambda_arg1(); 198 call_with_lambda_arg2(); 199 return define_lambda(); 200 } 201 202 namespace PR19361 { 203 struct A { 204 void foo() __restrict &; 205 void foo() __restrict &&; 206 }; foo()207void A::foo() __restrict & {} 208 // CHECK-DAG: @"?foo@A@PR19361@@QIGAEXXZ" foo()209void A::foo() __restrict && {} 210 // CHECK-DAG: @"?foo@A@PR19361@@QIHAEXXZ" 211 } 212 operator ""_deg(long double)213int operator"" _deg(long double) { return 0; } 214 // CHECK-DAG: @"??__K_deg@@YAHO@Z" 215 216 template <char...> templ_fun_with_pack()217void templ_fun_with_pack() {} 218 219 template void templ_fun_with_pack<>(); 220 // CHECK-DAG: @"??$templ_fun_with_pack@$S@@YAXXZ" 221 222 template <typename...> templ_fun_with_ty_pack()223void templ_fun_with_ty_pack() {} 224 225 template void templ_fun_with_ty_pack<>(); 226 // MSVC2013-DAG: @"??$templ_fun_with_ty_pack@$$$V@@YAXXZ" 227 // MSVC2015-DAG: @"??$templ_fun_with_ty_pack@$$V@@YAXXZ" 228 229 template <template <class> class...> templ_fun_with_templ_templ_pack()230void templ_fun_with_templ_templ_pack() {} 231 232 template void templ_fun_with_templ_templ_pack<>(); 233 // MSVC2013-DAG: @"??$templ_fun_with_templ_templ_pack@$$$V@@YAXXZ" 234 // MSVC2015-DAG: @"??$templ_fun_with_templ_templ_pack@$$V@@YAXXZ" 235 236 namespace PR20047 { 237 template <typename T> 238 struct A {}; 239 240 template <typename T> 241 using AliasA = A<T>; 242 243 template <template <typename> class> f()244void f() {} 245 246 template void f<AliasA>(); 247 // CHECK-DAG: @"??$f@$$YAliasA@PR20047@@@PR20047@@YAXXZ" 248 } 249 250 namespace UnnamedType { 251 struct A { 252 struct {} *TD; 253 }; 254 f(decltype(* A::TD) )255void f(decltype(*A::TD)) {} 256 // CHECK-DAG: @"?f@UnnamedType@@YAXAAU<unnamed-type-TD>@A@1@@Z" 257 258 template <typename T> 259 struct B { 260 enum { 261 } *e; 262 }; 263 f(decltype(B<int>::e) )264void f(decltype(B<int>::e)) {} 265 // CHECK-DAG: @"?f@UnnamedType@@YAXPAW4<unnamed-type-e>@?$B@H@1@@Z 266 } 267 268 namespace PR24651 { 269 template <typename T> f(T)270void f(T) {} 271 g()272void g() { 273 enum {} E; 274 f(E); 275 { 276 enum {} E; 277 f(E); 278 } 279 } 280 // CHECK-DAG: @"??$f@W4<unnamed-type-E>@?1??g@PR24651@@YAXXZ@@PR24651@@YAXW4<unnamed-type-E>@?1??g@0@YAXXZ@@Z" 281 // CHECK-DAG: @"??$f@W4<unnamed-type-E>@?2??g@PR24651@@YAXXZ@@PR24651@@YAXW4<unnamed-type-E>@?2??g@0@YAXXZ@@Z" 282 } 283 284 namespace PR18204 { 285 template <typename T> f(T *)286int f(T *) { return 0; } 287 static union { 288 int n = f(this); 289 }; 290 // CHECK-DAG: @"??$f@T<unnamed-type-$S1>@PR18204@@@PR18204@@YAHPAT<unnamed-type-$S1>@0@@Z" 291 } 292 PR26105()293int PR26105() { 294 auto add = [](int x) { return ([x](int y) { return x + y; }); }; 295 return add(3)(4); 296 } 297 // CHECK-DAG: @"??R<lambda_0>@?0??PR26105@@YAHXZ@QBE@H@Z" 298 // CHECK-DAG: @"??R<lambda_1>@?0???R<lambda_0>@?0??PR26105@@YAHXZ@QBE@H@Z@QBE@H@Z" 299 unaligned_foo1()300int __unaligned * unaligned_foo1() { return 0; } unaligned_foo2()301int __unaligned * __unaligned * unaligned_foo2() { return 0; } unaligned_foo3()302__unaligned int unaligned_foo3() { return 0; } unaligned_foo4(int __unaligned * p1)303void unaligned_foo4(int __unaligned *p1) {} unaligned_foo5(int __unaligned * __restrict p1)304void unaligned_foo5(int __unaligned * __restrict p1) {} unaligned_foo6(T t)305template <typename T> T unaligned_foo6(T t) { return t; } unaligned_foo7()306void unaligned_foo7() { unaligned_foo6<int *>(0); unaligned_foo6<int __unaligned *>(0); } 307 308 // CHECK-DAG: @"?unaligned_foo1@@YAPFAHXZ" 309 // CHECK-DAG: @"?unaligned_foo2@@YAPFAPFAHXZ" 310 // CHECK-DAG: @"?unaligned_foo3@@YAHXZ" 311 // CHECK-DAG: @"?unaligned_foo4@@YAXPFAH@Z" 312 // CHECK-DAG: @"?unaligned_foo5@@YAXPIFAH@Z" 313 // CHECK-DAG: @"??$unaligned_foo6@PAH@@YAPAHPAH@Z" 314 // CHECK-DAG: @"??$unaligned_foo6@PFAH@@YAPFAHPFAH@Z" 315 316 // __unaligned qualifier for function types 317 struct unaligned_foo8_S { 318 void unaligned_foo8() volatile __unaligned; 319 }; unaligned_foo8()320void unaligned_foo8_S::unaligned_foo8() volatile __unaligned {} 321 322 // CHECK-DAG: @"?unaligned_foo8@unaligned_foo8_S@@QFCEXXZ" 323 324 namespace PR31197 { 325 struct A { 326 // CHECK-DAG: define linkonce_odr dso_local x86_thiscallcc i32* @"??R<lambda_1>@x@A@PR31197@@QBE@XZ"( __anon7fd236d40c02PR31197::A327 int *x = []() { 328 static int white; 329 // CHECK-DAG: @"?white@?1???R<lambda_1>@x@A@PR31197@@QBE@XZ@4HA" 330 return &white; 331 }(); 332 // CHECK-DAG: define linkonce_odr dso_local x86_thiscallcc i32* @"??R<lambda_1>@y@A@PR31197@@QBE@XZ"( __anon7fd236d40d02PR31197::A333 int *y = []() { 334 static int black; 335 // CHECK-DAG: @"?black@?1???R<lambda_1>@y@A@PR31197@@QBE@XZ@4HA" 336 return &black; 337 }(); 338 using FPtrTy = void(void); __anon7fd236d41002PR31197::A339 static void default_args(FPtrTy x = [] {}, FPtrTy y = [] {}, int z = [] { return 1; }() + [] { return 2; }()) {} 340 // CHECK-DAG: @"??R<lambda_1_1>@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( 341 // CHECK-DAG: @"??R<lambda_1_2>@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( 342 // CHECK-DAG: @"??R<lambda_2_1>@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( 343 // CHECK-DAG: @"??R<lambda_3_1>@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"( 344 }; 345 A a; 346 347 int call_it = (A::default_args(), 1); 348 } 349 350 enum { enumerator }; f(decltype(enumerator) )351void f(decltype(enumerator)) {} 352 // CHECK-DAG: define internal void @"?f@@YAXW4<unnamed-enum-enumerator>@@@Z"( use_f()353void use_f() { f(enumerator); } 354 355 namespace pr37723 { 356 struct s { enum {}; enum {}; }; 357 // DBG-DAG: DW_TAG_enumeration_type{{.*}}identifier: ".?AW4<unnamed-type-$S2>@s@pr37723@@" 358 // DBG-DAG: DW_TAG_enumeration_type{{.*}}identifier: ".?AW4<unnamed-type-$S3>@s@pr37723@@" 359 s x; 360 } 361