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
5 namespace FTypeWithQuals
{
9 using A
= int () const;
11 // CHECK-DAG: @"?a@FTypeWithQuals@@3U?$S@$$A8@@BAHXZ@1@A"
13 using B
= int () volatile;
15 // CHECK-DAG: @"?b@FTypeWithQuals@@3U?$S@$$A8@@CAHXZ@1@A"
17 using C
= int () __restrict
;
19 // CHECK-DAG: @"?c@FTypeWithQuals@@3U?$S@$$A8@@IAAHXZ@1@A"
21 using D
= int () const &;
23 // CHECK-DAG: @"?d@FTypeWithQuals@@3U?$S@$$A8@@GBAHXZ@1@A"
25 using E
= int () volatile &;
27 // CHECK-DAG: @"?e@FTypeWithQuals@@3U?$S@$$A8@@GCAHXZ@1@A"
29 using F
= int () __restrict
&;
31 // CHECK-DAG: @"?f@FTypeWithQuals@@3U?$S@$$A8@@IGAAHXZ@1@A"
33 using G
= int () const &&;
35 // CHECK-DAG: @"?g@FTypeWithQuals@@3U?$S@$$A8@@HBAHXZ@1@A"
37 using H
= int () volatile &&;
39 // CHECK-DAG: @"?h@FTypeWithQuals@@3U?$S@$$A8@@HCAHXZ@1@A"
41 using I
= int () __restrict
&&;
43 // CHECK-DAG: @"?i@FTypeWithQuals@@3U?$S@$$A8@@IHAAHXZ@1@A"
47 // CHECK-DAG: @"?j@FTypeWithQuals@@3U?$S@$$A6AHXZ@1@A"
51 // CHECK-DAG: @"?k@FTypeWithQuals@@3U?$S@$$A8@@GAAHXZ@1@A"
55 // CHECK-DAG: @"?l@FTypeWithQuals@@3U?$S@$$A8@@HAAHXZ@1@A"
58 // CHECK: "?DeducedType@@3HA"
59 auto DeducedType
= 30;
61 // CHECK-DAG: @"?Char16Var@@3_SA"
64 // CHECK-DAG: @"?Char32Var@@3_UA"
67 // CHECK: "?LRef@@YAXAAH@Z"
70 // CHECK: "?RRef@@YAH$$QAH@Z"
71 int RRef(int&& a
) { return a
; }
73 // CHECK: "?Null@@YAX$$T@Z"
74 namespace std
{ typedef decltype(__nullptr
) nullptr_t
; }
75 void Null(std::nullptr_t
) {}
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"
104 decltype(Enum
) *UseEnum() { return &Enum
; }
105 decltype(BoolEnum
) *UseBoolEnum() { return &BoolEnum
; }
106 decltype(CharEnum
) *UseCharEnum() { return &CharEnum
; }
107 decltype(SCharEnum
) *UseSCharEnum() { return &SCharEnum
; }
108 decltype(UCharEnum
) *UseUCharEnum() { return &UCharEnum
; }
109 decltype(SShortEnum
) *UseSShortEnum() { return &SShortEnum
; }
110 decltype(UShortEnum
) *UseUShortEnum() { return &UShortEnum
; }
111 decltype(SIntEnum
) *UseSIntEnum() { return &SIntEnum
; }
112 decltype(UIntEnum
) *UseUIntEnum() { return &UIntEnum
; }
113 decltype(SLongEnum
) *UseSLongEnum() { return &SLongEnum
; }
114 decltype(ULongEnum
) *UseULongEnum() { return &ULongEnum
; }
115 decltype(SLongLongEnum
) *UseSLongLongEnum() { return &SLongLongEnum
; }
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"
143 decltype(EnumClass
) *UseEnumClass() { return &EnumClass
; }
144 decltype(BoolEnumClass
) *UseBoolEnumClass() { return &BoolEnumClass
; }
145 decltype(CharEnumClass
) *UseCharEnumClass() { return &CharEnumClass
; }
146 decltype(SCharEnumClass
) *UseSCharEnumClass() { return &SCharEnumClass
; }
147 decltype(UCharEnumClass
) *UseUCharEnumClass() { return &UCharEnumClass
; }
148 decltype(SShortEnumClass
) *UseSShortEnumClass() { return &SShortEnumClass
; }
149 decltype(UShortEnumClass
) *UseUShortEnumClass() { return &UShortEnumClass
; }
150 decltype(SIntEnumClass
) *UseSIntEnumClass() { return &SIntEnumClass
; }
151 decltype(UIntEnumClass
) *UseUIntEnumClass() { return &UIntEnumClass
; }
152 decltype(SLongEnumClass
) *UseSLongEnumClass() { return &SLongEnumClass
; }
153 decltype(ULongEnumClass
) *UseULongEnumClass() { return &ULongEnumClass
; }
154 decltype(SLongLongEnumClass
) *UseSLongLongEnumClass() { return &SLongLongEnumClass
; }
155 decltype(ULongLongEnumClass
) *UseULongLongEnumClass() { return &ULongLongEnumClass
; }
161 decltype(a
) fun(decltype(a
) x
, decltype(a
)) { return x
; }
162 // CHECK-DAG: @"?fun@PR18022@@YA?AU<unnamed-type-a>@1@U21@0@Z"
164 void use_fun() { fun(a
, a
); }
168 inline 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
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
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"
183 template <typename T
>
184 void use_lambda_arg(T
) {}
186 inline 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"
191 inline 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"
197 call_with_lambda_arg1();
198 call_with_lambda_arg2();
199 return define_lambda();
204 void foo() __restrict
&;
205 void foo() __restrict
&&;
207 void A::foo() __restrict
& {}
208 // CHECK-DAG: @"?foo@A@PR19361@@QIGAEXXZ"
209 void A::foo() __restrict
&& {}
210 // CHECK-DAG: @"?foo@A@PR19361@@QIHAEXXZ"
213 int operator"" _deg(long double) { return 0; }
214 // CHECK-DAG: @"??__K_deg@@YAHO@Z"
217 void templ_fun_with_pack() {}
219 template void templ_fun_with_pack
<>();
220 // CHECK-DAG: @"??$templ_fun_with_pack@$S@@YAXXZ"
222 template <typename
...>
223 void templ_fun_with_ty_pack() {}
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"
229 template <template <class> class...>
230 void templ_fun_with_templ_templ_pack() {}
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"
237 template <typename T
>
240 template <typename T
>
243 template <template <typename
> class>
246 template void f
<AliasA
>();
247 // CHECK-DAG: @"??$f@$$YAliasA@PR20047@@@PR20047@@YAXXZ"
250 namespace UnnamedType
{
255 void f(decltype(*A::TD
)) {}
256 // CHECK-DAG: @"?f@UnnamedType@@YAXAAU<unnamed-type-TD>@A@1@@Z"
258 template <typename T
>
264 void f(decltype(B
<int>::e
)) {}
265 // CHECK-DAG: @"?f@UnnamedType@@YAXPAW4<unnamed-type-e>@?$B@H@1@@Z
269 template <typename T
>
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"
285 template <typename T
>
286 int f(T
*) { return 0; }
290 // CHECK-DAG: @"??$f@T<unnamed-type-$S1>@PR18204@@@PR18204@@YAHPAT<unnamed-type-$S1>@0@@Z"
294 auto add
= [](int x
) { return ([x
](int y
) { return x
+ y
; }); };
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"
300 int __unaligned
* unaligned_foo1() { return 0; }
301 int __unaligned
* __unaligned
* unaligned_foo2() { return 0; }
302 __unaligned
int unaligned_foo3() { return 0; }
303 void unaligned_foo4(int __unaligned
*p1
) {}
304 void unaligned_foo5(int __unaligned
* __restrict p1
) {}
305 template <typename T
> T
unaligned_foo6(T t
) { return t
; }
306 void unaligned_foo7() { unaligned_foo6
<int *>(0); unaligned_foo6
<int __unaligned
*>(0); }
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"
316 // __unaligned qualifier for function types
317 struct unaligned_foo8_S
{
318 void unaligned_foo8() volatile __unaligned
;
320 void unaligned_foo8_S::unaligned_foo8() volatile __unaligned
{}
322 // CHECK-DAG: @"?unaligned_foo8@unaligned_foo8_S@@QFCEXXZ"
326 // CHECK-DAG: define linkonce_odr dso_local x86_thiscallcc noundef ptr @"??R<lambda_1>@x@A@PR31197@@QBE@XZ"(
329 // CHECK-DAG: @"?white@?1???R<lambda_1>@x@A@PR31197@@QBE@XZ@4HA"
332 // CHECK-DAG: define linkonce_odr dso_local x86_thiscallcc noundef ptr @"??R<lambda_1>@y@A@PR31197@@QBE@XZ"(
335 // CHECK-DAG: @"?black@?1???R<lambda_1>@y@A@PR31197@@QBE@XZ@4HA"
338 using FPtrTy
= void(void);
339 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"(
347 int call_it
= (A::default_args(), 1);
351 void f(decltype(enumerator
)) {}
352 // CHECK-DAG: define internal void @"?f@@YAXW4<unnamed-enum-enumerator>@@@Z"(
353 void use_f() { f(enumerator
); }
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@@"