1 // RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \
2 // RUN: -disable-llvm-passes -std=c++14 \
3 // RUN: -fno-dllexport-inlines -emit-llvm -O1 -o - | \
4 // RUN: FileCheck --check-prefix=CHECK --check-prefix=NOEXPORTINLINE %s
6 // RUN: %clang_cc1 %s -fms-extensions -triple x86_64-windows-msvc \
7 // RUN: -disable-llvm-passes -std=c++14 \
8 // RUN: -emit-llvm -O1 -o - | \
9 // RUN: FileCheck --check-prefix=CHECK --check-prefix=EXPORTINLINE %s
12 struct __declspec(dllexport
) ExportedClass
{
14 // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@ExportedClass@@
15 // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@ExportedClass@@
16 void InclassDefFunc() {}
18 // CHECK-DAG: define weak_odr dso_local dllexport noundef i32 @"?InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
19 int InclassDefFuncWithStaticVariable() {
20 // CHECK-DAG: @"?static_variable@?1??InclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
21 static int static_variable
= 0;
23 return static_variable
;
26 // CHECK-DAG: define weak_odr dso_local dllexport noundef i32 @"?InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ"
27 int InclassDefFunctWithLambdaStaticVariable() {
28 // CHECK-DAG: @"?static_x@?2???R<lambda_1>@?0??InclassDefFunctWithLambdaStaticVariable@ExportedClass@@QEAAHXZ@QEBA?A?<auto>@@XZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
29 return ([]() { static int static_x
; return ++static_x
; })();
32 // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
33 // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InlineOutclassDefFunc@ExportedClass@@QEAAXXZ
34 inline void InlineOutclassDefFunc();
36 // CHECK-DAG: define weak_odr dso_local dllexport noundef i32 @"?InlineOutclassDefFuncWithStaticVariable@ExportedClass@@QEAAHXZ"
37 inline int InlineOutclassDefFuncWithStaticVariable();
39 // CHECK-DAG: define dso_local dllexport void @"?OutoflineDefFunc@ExportedClass@@QEAAXXZ"
40 void OutoflineDefFunc();
43 void ExportedClass::OutoflineDefFunc() {}
45 inline void ExportedClass::InlineOutclassDefFunc() {}
47 inline int ExportedClass::InlineOutclassDefFuncWithStaticVariable() {
48 static int static_variable
= 0;
49 return ++static_variable
;
52 void ExportedClassUser() {
55 a
.InlineOutclassDefFunc();
59 struct __declspec(dllexport
) TemplateExportedClass
{
60 void InclassDefFunc() {}
62 int InclassDefFuncWithStaticVariable() {
63 static int static_x
= 0;
71 // CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VA11@@@@QEAAXXZ"
72 // CHECK-DAG: define weak_odr dso_local dllexport noundef i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11@@@@QEAAHXZ"
73 // CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VA11@@@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
74 template class TemplateExportedClass
<A11
>;
76 // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InclassDefFunc@?$TemplateExportedClass@VB22@@@@QEAAXXZ"
77 // EXPORTINLINE-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateExportedClass@VB22@@@@QEAAXXZ
78 // CHECK-DAG: define weak_odr dso_local dllexport noundef i32 @"?InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VB22@@@@QEAAHXZ"
79 // CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticVariable@?$TemplateExportedClass@VB22@@@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
80 TemplateExportedClass
<B22
> b22
;
82 void TemplateExportedClassUser() {
84 b22
.InclassDefFuncWithStaticVariable();
89 struct TemplateNoAttributeClass
{
90 void InclassDefFunc() {}
91 int InclassDefFuncWithStaticLocal() {
97 // CHECK-DAG: define weak_odr dso_local dllexport void @"?InclassDefFunc@?$TemplateNoAttributeClass@VA11@@@@QEAAXXZ"
98 // CHECK-DAG: define weak_odr dso_local dllexport noundef i32 @"?InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VA11
99 // CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VA11@@@@QEAAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
100 template class __declspec(dllexport
) TemplateNoAttributeClass
<A11
>;
102 // CHECK-DAG: define available_externally dllimport void @"?InclassDefFunc@?$TemplateNoAttributeClass@VB22@@@@QEAAXXZ"
103 // CHECK-DAG: define available_externally dllimport noundef i32 @"?InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VB22@@@@QEAAHXZ"
104 // CHECK-DAG: @"?static_x@?2??InclassDefFuncWithStaticLocal@?$TemplateNoAttributeClass@VB22@@@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4
105 extern template class __declspec(dllimport
) TemplateNoAttributeClass
<B22
>;
107 void TemplateNoAttributeClassUser() {
108 TemplateNoAttributeClass
<B22
> b22
;
109 b22
.InclassDefFunc();
110 b22
.InclassDefFuncWithStaticLocal();
113 struct __declspec(dllimport
) ImportedClass
{
114 // NOEXPORTINLINE-DAG: define linkonce_odr dso_local void @"?InClassDefFunc@ImportedClass@@QEAAXXZ"
115 // EXPORTINLINE-DAG: define available_externally dllimport void @"?InClassDefFunc@ImportedClass@@QEAAXXZ"
116 void InClassDefFunc() {}
118 // EXPORTINLINE-DAG: define available_externally dllimport noundef i32 @"?InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ"
119 // NOEXPORTINLINE-DAG: define linkonce_odr dso_local noundef i32 @"?InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ"
120 int InClassDefFuncWithStaticVariable() {
121 // CHECK-DAG: @"?static_variable@?1??InClassDefFuncWithStaticVariable@ImportedClass@@QEAAHXZ@4HA" = available_externally dllimport global i32 0, align 4
122 static int static_variable
= 0;
124 return static_variable
;
128 int InClassDefFuncUser() {
129 // This is necessary for declare statement of ImportedClass::InClassDefFunc().
132 return c
.InClassDefFuncWithStaticVariable();