1 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-passes -o - %s -w -fms-compatibility-version=19.00 | FileCheck -allow-deprecated-dag-overlap --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2015 %s
2 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O1 -mconstructor-aliases -disable-llvm-passes -o - %s -w -fms-compatibility-version=18.00 | FileCheck -allow-deprecated-dag-overlap --check-prefix=MSC --check-prefix=M32 -check-prefix=MSVC2013 -check-prefix=M32MSVC2013 %s
4 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=19.00 | FileCheck -allow-deprecated-dag-overlap --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2015 %s
5 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w -fms-compatibility-version=18.00 | FileCheck -allow-deprecated-dag-overlap --check-prefix=MSC --check-prefix=M64 -check-prefix=MSVC2013 %s
7 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck -allow-deprecated-dag-overlap --check-prefix=GNU --check-prefix=G32 %s
8 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-gnu -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck -allow-deprecated-dag-overlap --check-prefix=GNU %s
9 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-scei-ps4 -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck -allow-deprecated-dag-overlap --check-prefix=PS %s
10 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-sie-ps5 -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck -allow-deprecated-dag-overlap --check-prefix=PS %s
12 // Helper structs to make templates more expressive.
13 struct ImplicitInst_Exported
{};
14 struct ExplicitDecl_Exported
{};
15 struct ExplicitInst_Exported
{};
16 struct ExplicitSpec_Exported
{};
17 struct ExplicitSpec_Def_Exported
{};
18 struct ExplicitSpec_InlineDef_Exported
{};
19 struct ExplicitSpec_NotExported
{};
20 struct External
{ int v
; };
22 #define JOIN2(x, y) x##y
23 #define JOIN(x, y) JOIN2(x, y)
24 #define UNIQ(name) JOIN(name, __LINE__)
25 #define USEVAR(var) int UNIQ(use)() { return var; }
26 #define USE(func) void UNIQ(use)() { func(); }
27 #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; }
28 #define INSTVAR(var) template int var;
29 #define INST(func) template void func();
31 // The vftable for struct W is comdat largest because we have RTTI.
32 // M32-DAG: $"??_7W@@6B@" = comdat largest
34 // M32-DAG: $"?smember@?$Base@H@PR32992@@0HA" = comdat any
37 //===----------------------------------------------------------------------===//
39 //===----------------------------------------------------------------------===//
41 // Declarations are not exported.
42 // MSC-NOT: @"?ExternGlobalDecl@@3HA"
43 // GNU-NOT: @ExternGlobalDecl
44 __declspec(dllexport
) extern int ExternGlobalDecl
;
46 // M64-DAG: @__ImageBase = external dso_local constant i8
48 // GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external global
50 // dllexport implies a definition.
51 // MSC-DAG: @"?GlobalDef@@3HA" = dso_local dllexport global i32 0, align 4
52 // GNU-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4
53 __declspec(dllexport
) int GlobalDef
;
56 // MSC-DAG: @"?GlobalInit1@@3HA" = dso_local dllexport global i32 1, align 4
57 // GNU-DAG: @GlobalInit1 = dso_local dllexport global i32 1, align 4
58 __declspec(dllexport
) int GlobalInit1
= 1;
60 // MSC-DAG: @"?GlobalInit2@@3HA" = dso_local dllexport global i32 1, align 4
61 // GNU-DAG: @GlobalInit2 = dso_local dllexport global i32 1, align 4
62 int __declspec(dllexport
) GlobalInit2
= 1;
64 // Declare, then export definition.
65 // MSC-DAG: @"?GlobalDeclInit@@3HA" = dso_local dllexport global i32 1, align 4
66 // GNU-DAG: @GlobalDeclInit = dso_local dllexport global i32 1, align 4
67 __declspec(dllexport
) extern int GlobalDeclInit
;
68 int GlobalDeclInit
= 1;
71 // MSC-DAG: @"?GlobalRedecl1@@3HA" = dso_local dllexport global i32 0, align 4
72 // GNU-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4
73 __declspec(dllexport
) extern int GlobalRedecl1
;
74 __declspec(dllexport
) int GlobalRedecl1
;
76 // MSC-DAG: @"?GlobalRedecl2@@3HA" = dso_local dllexport global i32 0, align 4
77 // GNU-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4
78 __declspec(dllexport
) extern int GlobalRedecl2
;
81 // MSC-DAG: @"?ExternalGlobal@ns@@3HA" = dso_local dllexport global i32 0, align 4
82 // GNU-DAG: @_ZN2ns14ExternalGlobalE = dso_local dllexport global i32 0, align 4
83 namespace ns
{ __declspec(dllexport
) int ExternalGlobal
; }
85 // MSC-DAG: @"?ExternalAutoTypeGlobal@@3UExternal@@A" = dso_local dllexport global %struct.External zeroinitializer, align 4
86 // GNU-DAG: @ExternalAutoTypeGlobal = dso_local dllexport global %struct.External zeroinitializer, align 4
87 __declspec(dllexport
) auto ExternalAutoTypeGlobal
= External();
90 // MSC-DAG: @"?x@?1??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0
91 // MSC-DAG: @"?$S1@?1??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0
92 int __declspec(dllexport
) nonInlineStaticLocalsFunc() {
97 // MSC-DAG: @"?x@?1??inlineStaticLocalsFunc@@YAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat
98 // MSC-DAG: @"??_B?1??inlineStaticLocalsFunc@@YAHXZ@51" = weak_odr dllexport global i32 0, comdat
99 // Note: MinGW doesn't seem to export the static local here.
100 inline int __declspec(dllexport
) inlineStaticLocalsFunc() {
106 // Static data members of a instantiated base class should be exported.
109 virtual void myfunc() {}
112 // MSC-DAG: @"?smember@?$Base@H@PR32992@@0HA" = weak_odr dso_local dllexport global i32 77, comdat, align 4
113 template <class T
> int Base
<T
>::smember
= 77;
115 class __declspec(dllexport
) Derived2
: Base
<T
> {
118 class Derived
: public Derived2
<int> {
121 } // namespace PR32992
123 namespace PR32992_1
{
124 namespace a
{ enum b
{ c
}; }
125 template <typename
> class d
{
126 static constexpr a::b e
= a::c
;
129 template <typename g
= int> class h
: d
<g
> {};
132 class __declspec(dllexport
) i
: h
<> {};
135 //===----------------------------------------------------------------------===//
136 // Variable templates
137 //===----------------------------------------------------------------------===//
139 // Declarations are not exported.
141 // MSC-DAG: @"??$VarTmplImplicitDef@UImplicitInst_Exported@@@@3HA" = external dso_local global
142 // GNU-DAG: @_Z18VarTmplImplicitDefI21ImplicitInst_ExportedE = external global
143 template<typename T
> __declspec(dllexport
) extern int VarTmplImplicitDef
;
144 USEVAR(VarTmplImplicitDef
<ImplicitInst_Exported
>)
146 // Export definition.
147 // MSC-DAG: @"??$VarTmplInit1@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
148 // GNU-DAG: @_Z12VarTmplInit1I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
149 template<typename T
> __declspec(dllexport
) int VarTmplInit1
= 1;
150 INSTVAR(VarTmplInit1
<ExplicitInst_Exported
>)
152 // MSC-DAG: @"??$VarTmplInit2@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
153 // GNU-DAG: @_Z12VarTmplInit2I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
154 template<typename T
> int __declspec(dllexport
) VarTmplInit2
= 1;
155 INSTVAR(VarTmplInit2
<ExplicitInst_Exported
>)
157 // Declare, then export definition.
158 // MSC-DAG: @"??$VarTmplDeclInit@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
159 // GNU-DAG: @_Z15VarTmplDeclInitI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
160 template<typename T
> __declspec(dllexport
) extern int VarTmplDeclInit
;
161 template<typename T
> int VarTmplDeclInit
= 1;
162 INSTVAR(VarTmplDeclInit
<ExplicitInst_Exported
>)
165 // MSC-DAG: @"??$VarTmplRedecl1@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
166 // GNU-DAG: @_Z14VarTmplRedecl1I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
167 template<typename T
> __declspec(dllexport
) extern int VarTmplRedecl1
;
168 template<typename T
> __declspec(dllexport
) int VarTmplRedecl1
= 1;
169 INSTVAR(VarTmplRedecl1
<ExplicitInst_Exported
>)
171 // MSC-DAG: @"??$VarTmplRedecl2@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
172 // GNU-DAG: @_Z14VarTmplRedecl2I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
173 template<typename T
> __declspec(dllexport
) extern int VarTmplRedecl2
;
174 template<typename T
> int VarTmplRedecl2
= 1;
175 INSTVAR(VarTmplRedecl2
<ExplicitInst_Exported
>)
177 // MSC-DAG: @"??$ExternalVarTmpl@UExplicitInst_Exported@@@ns@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
178 // GNU-DAG: @_ZN2ns15ExternalVarTmplI21ExplicitInst_ExportedEE = weak_odr dso_local dllexport global i32 1, comdat, align 4
179 namespace ns
{ template<typename T
> __declspec(dllexport
) int ExternalVarTmpl
= 1; }
180 INSTVAR(ns::ExternalVarTmpl
<ExplicitInst_Exported
>)
182 // MSC-DAG: @"??$ExternalAutoTypeVarTmpl@UExplicitInst_Exported@@@@3UExternal@@A" = weak_odr dso_local dllexport global %struct.External zeroinitializer, comdat, align 4
183 // GNU-DAG: @_Z23ExternalAutoTypeVarTmplI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global %struct.External zeroinitializer, comdat, align 4
184 template<typename T
> __declspec(dllexport
) auto ExternalAutoTypeVarTmpl
= External();
185 template External ExternalAutoTypeVarTmpl
<ExplicitInst_Exported
>;
188 template<typename T
> int VarTmpl
= 1;
189 template<typename T
> __declspec(dllexport
) int ExportedVarTmpl
= 1;
191 // Export implicit instantiation of an exported variable template.
192 // MSC-DAG: @"??$ExportedVarTmpl@UImplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
193 // GNU-DAG: @_Z15ExportedVarTmplI21ImplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
194 USEVAR(ExportedVarTmpl
<ImplicitInst_Exported
>)
196 // Export explicit instantiation declaration of an exported variable template.
197 // MSC-DAG: @"??$ExportedVarTmpl@UImplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
198 // GNU-DAG: @_Z15ExportedVarTmplI21ExplicitDecl_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
199 extern template int ExportedVarTmpl
<ExplicitDecl_Exported
>;
200 template int ExportedVarTmpl
<ExplicitDecl_Exported
>;
202 // Export explicit instantiation definition of an exported variable template.
203 // MSC-DAG: @"??$ExportedVarTmpl@UImplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
204 // GNU-DAG: @_Z15ExportedVarTmplI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
205 template __declspec(dllexport
) int ExportedVarTmpl
<ExplicitInst_Exported
>;
207 // Export specialization of an exported variable template.
208 // MSC-DAG: @"??$ExportedVarTmpl@UExplicitSpec_Exported@@@@3HA" = dso_local dllexport global i32 0, align 4
209 // GNU-DAG: @_Z15ExportedVarTmplI21ExplicitSpec_ExportedE = dso_local dllexport global i32 0, align 4
210 template<> __declspec(dllexport
) int ExportedVarTmpl
<ExplicitSpec_Exported
>;
212 // MSC-DAG: @"??$ExportedVarTmpl@UExplicitSpec_Def_Exported@@@@3HA" = dso_local dllexport global i32 1, align 4
213 // GNU-DAG: @_Z15ExportedVarTmplI25ExplicitSpec_Def_ExportedE = dso_local dllexport global i32 1, align 4
214 template<> __declspec(dllexport
) int ExportedVarTmpl
<ExplicitSpec_Def_Exported
> = 1;
216 // Not exporting specialization of an exported variable template without
217 // explicit dllexport.
218 // MSC-DAG: @"??$ExportedVarTmpl@UExplicitSpec_NotExported@@@@3HA" = dso_local global i32 0, align 4
219 // GNU-DAG: @_Z15ExportedVarTmplI24ExplicitSpec_NotExportedE = dso_local global i32 0, align 4
220 template<> int ExportedVarTmpl
<ExplicitSpec_NotExported
>;
223 // Export explicit instantiation declaration of a non-exported variable template.
224 // MSC-DAG: @"??$VarTmpl@UExplicitDecl_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
225 // GNU-DAG: @_Z7VarTmplI21ExplicitDecl_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
226 extern template __declspec(dllexport
) int VarTmpl
<ExplicitDecl_Exported
>;
227 template __declspec(dllexport
) int VarTmpl
<ExplicitDecl_Exported
>;
229 // Export explicit instantiation definition of a non-exported variable template.
230 // MSC-DAG: @"??$VarTmpl@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4
231 // GNU-DAG: @_Z7VarTmplI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4
232 template __declspec(dllexport
) int VarTmpl
<ExplicitInst_Exported
>;
234 // Export specialization of a non-exported variable template.
235 // MSC-DAG: @"??$VarTmpl@UExplicitSpec_Exported@@@@3HA" = dso_local dllexport global i32 0, align 4
236 // GNU-DAG: @_Z7VarTmplI21ExplicitSpec_ExportedE = dso_local dllexport global i32 0, align 4
237 template<> __declspec(dllexport
) int VarTmpl
<ExplicitSpec_Exported
>;
239 // MSC-DAG: @"??$VarTmpl@UExplicitSpec_Def_Exported@@@@3HA" = dso_local dllexport global i32 1, align 4
240 // GNU-DAG: @_Z7VarTmplI25ExplicitSpec_Def_ExportedE = dso_local dllexport global i32 1, align 4
241 template<> __declspec(dllexport
) int VarTmpl
<ExplicitSpec_Def_Exported
> = 1;
245 //===----------------------------------------------------------------------===//
247 //===----------------------------------------------------------------------===//
249 // Declarations are not exported.
251 // Export function definition.
252 // MSC-DAG: define dso_local dllexport void @"?def@@YAXXZ"()
253 // GNU-DAG: define dso_local dllexport void @_Z3defv()
254 __declspec(dllexport
) void def() {}
257 // MSC-DAG: define dso_local dllexport void @externC()
258 // GNU-DAG: define dso_local dllexport void @externC()
259 extern "C" __declspec(dllexport
) void externC() {}
261 // Export inline function.
262 // MSC-DAG: define weak_odr dso_local dllexport void @"?inlineFunc@@YAXXZ"()
263 // GNU-DAG: define weak_odr dso_local dllexport void @_Z10inlineFuncv()
264 __declspec(dllexport
) inline void inlineFunc() {}
266 // MSC-DAG: define weak_odr dso_local dllexport void @"?inlineDecl@@YAXXZ"()
267 // GNU-DAG: define weak_odr dso_local dllexport void @_Z10inlineDeclv()
268 __declspec(dllexport
) inline void inlineDecl();
271 // MSC-DAG: define weak_odr dso_local dllexport void @"?inlineDef@@YAXXZ"()
272 // GNU-DAG: define weak_odr dso_local dllexport void @_Z9inlineDefv()
273 __declspec(dllexport
) void inlineDef();
274 inline void inlineDef() {}
277 // MSC-DAG: define dso_local dllexport void @"?redecl1@@YAXXZ"()
278 // GNU-DAG: define dso_local dllexport void @_Z7redecl1v()
279 __declspec(dllexport
) void redecl1();
280 __declspec(dllexport
) void redecl1() {}
282 // MSC-DAG: define dso_local dllexport void @"?redecl2@@YAXXZ"()
283 // GNU-DAG: define dso_local dllexport void @_Z7redecl2v()
284 __declspec(dllexport
) void redecl2();
288 // MSC-DAG: define dso_local dllexport void @"?friend1@@YAXXZ"()
289 // GNU-DAG: define dso_local dllexport void @_Z7friend1v()
290 // MSC-DAG: define dso_local dllexport void @"?friend2@@YAXXZ"()
291 // GNU-DAG: define dso_local dllexport void @_Z7friend2v()
293 friend __declspec(dllexport
) void friend1();
294 friend __declspec(dllexport
) void friend2();
296 __declspec(dllexport
) void friend1() {}
299 // MSC-DAG: define dso_local dllexport void @"?func@Befriended@@SAXXZ"()
300 // GNU-DAG: define dso_local dllexport void @_ZN10Befriended4funcEv()
301 struct __declspec(dllexport
) Befriended
{
304 friend void Befriended::func();
307 void Befriended::func() {}
309 // Implicit declarations can be redeclared with dllexport.
310 // MSC-DAG: define dso_local dllexport nonnull ptr @"??2@{{YAPAXI|YAPEAX_K}}@Z"(
311 // GNU-DAG: define dso_local dllexport nonnull ptr @_Znw{{[yj]}}(
312 void* alloc(__SIZE_TYPE__ n
);
313 __declspec(dllexport
) void* operator new(__SIZE_TYPE__ n
) { return alloc(n
); }
315 // MSC-DAG: define dso_local dllexport void @"?externalFunc@ns@@YAXXZ"()
316 // GNU-DAG: define dso_local dllexport void @_ZN2ns12externalFuncEv()
317 namespace ns
{ __declspec(dllexport
) void externalFunc() {} }
321 //===----------------------------------------------------------------------===//
322 // Function templates
323 //===----------------------------------------------------------------------===//
325 // Export function template definition.
326 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplDef@UExplicitInst_Exported@@@@YAXXZ"()
327 // GNU-DAG: define weak_odr dso_local dllexport void @_Z11funcTmplDefI21ExplicitInst_ExportedEvv()
328 template<typename T
> __declspec(dllexport
) void funcTmplDef() {}
329 INST(funcTmplDef
<ExplicitInst_Exported
>)
331 // Export inline function template.
332 // MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmpl1@UExplicitInst_Exported@@@@YAXXZ"()
333 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15inlineFuncTmpl1I21ExplicitInst_ExportedEvv()
334 template<typename T
> __declspec(dllexport
) inline void inlineFuncTmpl1() {}
335 INST(inlineFuncTmpl1
<ExplicitInst_Exported
>)
337 // MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmpl2@UExplicitInst_Exported@@@@YAXXZ"()
338 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15inlineFuncTmpl2I21ExplicitInst_ExportedEvv()
339 template<typename T
> inline void __attribute__((dllexport
)) inlineFuncTmpl2() {}
340 INST(inlineFuncTmpl2
<ExplicitInst_Exported
>)
342 // MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmplDecl@UExplicitInst_Exported@@@@YAXXZ"()
343 // GNU-DAG: define weak_odr dso_local dllexport void @_Z18inlineFuncTmplDeclI21ExplicitInst_ExportedEvv()
344 template<typename T
> __declspec(dllexport
) inline void inlineFuncTmplDecl();
345 template<typename T
> void inlineFuncTmplDecl() {}
346 INST(inlineFuncTmplDecl
<ExplicitInst_Exported
>)
348 // MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmplDef@UExplicitInst_Exported@@@@YAXXZ"()
349 // GNU-DAG: define weak_odr dso_local dllexport void @_Z17inlineFuncTmplDefI21ExplicitInst_ExportedEvv()
350 template<typename T
> __declspec(dllexport
) void inlineFuncTmplDef();
351 template<typename T
> inline void inlineFuncTmplDef() {}
352 INST(inlineFuncTmplDef
<ExplicitInst_Exported
>)
356 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplRedecl1@UExplicitInst_Exported@@@@YAXXZ"()
357 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplRedecl1I21ExplicitInst_ExportedEvv()
358 template<typename T
> __declspec(dllexport
) void funcTmplRedecl1();
359 template<typename T
> __declspec(dllexport
) void funcTmplRedecl1() {}
360 INST(funcTmplRedecl1
<ExplicitInst_Exported
>)
362 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplRedecl2@UExplicitInst_Exported@@@@YAXXZ"()
363 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplRedecl2I21ExplicitInst_ExportedEvv()
364 template<typename T
> __declspec(dllexport
) void funcTmplRedecl2();
365 template<typename T
> void funcTmplRedecl2() {}
366 INST(funcTmplRedecl2
<ExplicitInst_Exported
>)
368 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplRedecl3@UExplicitInst_Exported@@@@YAXXZ"()
369 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplRedecl3I21ExplicitInst_ExportedEvv()
370 template<typename T
> __declspec(dllexport
) void funcTmplRedecl3();
371 template<typename T
> void funcTmplRedecl3() {}
372 INST(funcTmplRedecl3
<ExplicitInst_Exported
>)
375 // Function template friends
376 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplFriend1@UExplicitInst_Exported@@@@YAXXZ"()
377 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplFriend1I21ExplicitInst_ExportedEvv()
378 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplFriend2@UExplicitInst_Exported@@@@YAXXZ"()
379 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplFriend2I21ExplicitInst_ExportedEvv()
380 struct FuncTmplFriend
{
381 template<typename T
> friend __declspec(dllexport
) void funcTmplFriend1();
382 template<typename T
> friend __declspec(dllexport
) void funcTmplFriend2();
384 template<typename T
> __declspec(dllexport
) void funcTmplFriend1() {}
385 template<typename T
> void funcTmplFriend2() {}
386 INST(funcTmplFriend1
<ExplicitInst_Exported
>)
387 INST(funcTmplFriend2
<ExplicitInst_Exported
>)
389 // MSC-DAG: define weak_odr dso_local dllexport void @"??$externalFuncTmpl@UExplicitInst_Exported@@@ns@@YAXXZ"()
390 // GNU-DAG: define weak_odr dso_local dllexport void @_ZN2ns16externalFuncTmplI21ExplicitInst_ExportedEEvv()
391 namespace ns
{ template<typename T
> __declspec(dllexport
) void externalFuncTmpl() {} }
392 INST(ns::externalFuncTmpl
<ExplicitInst_Exported
>)
395 template<typename T
> void funcTmpl() {}
396 template<typename T
> __declspec(dllexport
) void exportedFuncTmpl() {}
398 // Export implicit instantiation of an exported function template.
399 // MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UImplicitInst_Exported@@@@YAXXZ"()
400 // GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI21ImplicitInst_ExportedEvv()
401 USE(exportedFuncTmpl
<ImplicitInst_Exported
>)
403 // Export explicit instantiation declaration of an exported function template.
404 // MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UExplicitDecl_Exported@@@@YAXXZ"()
405 // GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI21ExplicitDecl_ExportedEvv()
406 extern template void exportedFuncTmpl
<ExplicitDecl_Exported
>();
407 template void exportedFuncTmpl
<ExplicitDecl_Exported
>();
409 // Export explicit instantiation definition of an exported function template.
410 // MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UExplicitInst_Exported@@@@YAXXZ"()
411 // GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI21ExplicitInst_ExportedEvv()
412 template void exportedFuncTmpl
<ExplicitInst_Exported
>();
414 // Export specialization of an exported function template.
415 // MSC-DAG: define dso_local dllexport void @"??$exportedFuncTmpl@UExplicitSpec_Def_Exported@@@@YAXXZ"()
416 // GNU-DAG: define dso_local dllexport void @_Z16exportedFuncTmplI25ExplicitSpec_Def_ExportedEvv()
417 template<> __declspec(dllexport
) void exportedFuncTmpl
<ExplicitSpec_Def_Exported
>() {}
419 // MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UExplicitSpec_InlineDef_Exported@@@@YAXXZ"()
420 // GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI31ExplicitSpec_InlineDef_ExportedEvv()
421 template<> __declspec(dllexport
) inline void exportedFuncTmpl
<ExplicitSpec_InlineDef_Exported
>() {}
423 // Not exporting specialization of an exported function template without
424 // explicit dllexport.
425 // MSC-DAG: define dso_local void @"??$exportedFuncTmpl@UExplicitSpec_NotExported@@@@YAXXZ"()
426 // GNU-DAG: define dso_local void @_Z16exportedFuncTmplI24ExplicitSpec_NotExportedEvv()
427 template<> void exportedFuncTmpl
<ExplicitSpec_NotExported
>() {}
430 // Export explicit instantiation declaration of a non-exported function template.
431 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmpl@UExplicitDecl_Exported@@@@YAXXZ"()
432 // GNU-DAG: define weak_odr dso_local dllexport void @_Z8funcTmplI21ExplicitDecl_ExportedEvv()
433 extern template __declspec(dllexport
) void funcTmpl
<ExplicitDecl_Exported
>();
434 template __declspec(dllexport
) void funcTmpl
<ExplicitDecl_Exported
>();
436 // Export explicit instantiation definition of a non-exported function template.
437 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmpl@UExplicitInst_Exported@@@@YAXXZ"()
438 // GNU-DAG: define weak_odr dso_local dllexport void @_Z8funcTmplI21ExplicitInst_ExportedEvv()
439 template __declspec(dllexport
) void funcTmpl
<ExplicitInst_Exported
>();
441 // Export specialization of a non-exported function template.
442 // MSC-DAG: define dso_local dllexport void @"??$funcTmpl@UExplicitSpec_Def_Exported@@@@YAXXZ"()
443 // GNU-DAG: define dso_local dllexport void @_Z8funcTmplI25ExplicitSpec_Def_ExportedEvv()
444 template<> __declspec(dllexport
) void funcTmpl
<ExplicitSpec_Def_Exported
>() {}
446 // MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmpl@UExplicitSpec_InlineDef_Exported@@@@YAXXZ"()
447 // GNU-DAG: define weak_odr dso_local dllexport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ExportedEvv()
448 template<> __declspec(dllexport
) inline void funcTmpl
<ExplicitSpec_InlineDef_Exported
>() {}
452 //===----------------------------------------------------------------------===//
454 //===----------------------------------------------------------------------===//
456 // dllexport takes precedence over the dllimport if both are specified.
457 // MSC-DAG: @"?PrecedenceGlobal1A@@3HA" = dso_local dllexport global i32 0, align 4
458 // MSC-DAG: @"?PrecedenceGlobal1B@@3HA" = dso_local dllexport global i32 0, align 4
459 // GNU-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4
460 // GNU-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4
461 __attribute__((dllimport
, dllexport
)) int PrecedenceGlobal1A
; // dllimport ignored
462 __declspec(dllimport
) __declspec(dllexport
) int PrecedenceGlobal1B
; // dllimport ignored
464 // MSC-DAG: @"?PrecedenceGlobal2A@@3HA" = dso_local dllexport global i32 0, align 4
465 // MSC-DAG: @"?PrecedenceGlobal2B@@3HA" = dso_local dllexport global i32 0, align 4
466 // GNU-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4
467 // GNU-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4
468 __attribute__((dllexport
, dllimport
)) int PrecedenceGlobal2A
; // dllimport ignored
469 __declspec(dllexport
) __declspec(dllimport
) int PrecedenceGlobal2B
; // dllimport ignored
471 // MSC-DAG: @"?PrecedenceGlobalRedecl1@@3HA" = dso_local dllexport global i32 0, align 4
472 // GNU-DAG: @PrecedenceGlobalRedecl1 = dso_local dllexport global i32 0, align 4
473 __declspec(dllexport
) extern int PrecedenceGlobalRedecl1
;
474 __declspec(dllimport
) int PrecedenceGlobalRedecl1
= 0;
476 // MSC-DAG: @"?PrecedenceGlobalRedecl2@@3HA" = dso_local dllexport global i32 0, align 4
477 // GNU-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4
478 __declspec(dllimport
) extern int PrecedenceGlobalRedecl2
;
479 __declspec(dllexport
) int PrecedenceGlobalRedecl2
;
481 // MSC-DAG: @"?PrecedenceGlobalMixed1@@3HA" = dso_local dllexport global i32 0, align 4
482 // GNU-DAG: @PrecedenceGlobalMixed1 = dso_local dllexport global i32 0, align 4
483 __attribute__((dllexport
)) extern int PrecedenceGlobalMixed1
;
484 __declspec(dllimport
) int PrecedenceGlobalMixed1
= 0;
486 // MSC-DAG: @"?PrecedenceGlobalMixed2@@3HA" = dso_local dllexport global i32 0, align 4
487 // GNU-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4
488 __attribute__((dllimport
)) extern int PrecedenceGlobalMixed2
;
489 __declspec(dllexport
) int PrecedenceGlobalMixed2
;
491 // MSC-DAG: define dso_local dllexport void @"?precedence1A@@YAXXZ"
492 // MSC-DAG: define dso_local dllexport void @"?precedence1B@@YAXXZ"
493 // GNU-DAG: define dso_local dllexport void @_Z12precedence1Av()
494 // GNU-DAG: define dso_local dllexport void @_Z12precedence1Bv()
495 void __attribute__((dllimport
, dllexport
)) precedence1A() {}
496 void __declspec(dllimport
) __declspec(dllexport
) precedence1B() {}
498 // MSC-DAG: define dso_local dllexport void @"?precedence2A@@YAXXZ"
499 // MSC-DAG: define dso_local dllexport void @"?precedence2B@@YAXXZ"
500 // GNU-DAG: define dso_local dllexport void @_Z12precedence2Av()
501 // GNU-DAG: define dso_local dllexport void @_Z12precedence2Bv()
502 void __attribute__((dllexport
, dllimport
)) precedence2A() {}
503 void __declspec(dllexport
) __declspec(dllimport
) precedence2B() {}
505 // MSC-DAG: define dso_local dllexport void @"?precedenceRedecl1@@YAXXZ"
506 // GNU-DAG: define dso_local dllexport void @_Z17precedenceRedecl1v()
507 void __declspec(dllimport
) precedenceRedecl1();
508 void __declspec(dllexport
) precedenceRedecl1() {}
510 // MSC-DAG: define dso_local dllexport void @"?precedenceRedecl2@@YAXXZ"
511 // GNU-DAG: define dso_local dllexport void @_Z17precedenceRedecl2v()
512 void __declspec(dllexport
) precedenceRedecl2();
513 void __declspec(dllimport
) precedenceRedecl2() {}
517 //===----------------------------------------------------------------------===//
519 //===----------------------------------------------------------------------===//
522 void __declspec(dllexport
) a() {}
523 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?a@S@@QAEXXZ"
526 void __declspec(dllexport
) a() {}
527 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?a@T@S@@QAEXXZ"
531 template <typename T
>
532 struct SomeTemplate
{
533 SomeTemplate(T o
= T()) : o(o
) {}
536 // MSVC2015-DAG: define weak_odr dso_local dllexport {{.+}} @"??4?$SomeTemplate@H@@Q{{.+}}@$$Q{{.+}}@@Z"
537 // MSVC2013-DAG: define weak_odr dso_local dllexport {{.+}} @"??4?$SomeTemplate@H@@Q{{.+}}0@A{{.+}}0@@Z"
538 struct __declspec(dllexport
) InheritFromTemplate
: SomeTemplate
<int> {};
540 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??_F?$SomeTemplate@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
551 struct __declspec(dllexport
) B
{
557 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FB@PR23801@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat
559 struct __declspec(dllexport
) T
{
560 // Copy assignment operator:
561 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"??4T@@QAEAAU0@ABU0@@Z"
563 // Explicitly defaulted copy constructur:
564 T(const T
&) = default;
565 // M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0T@@QAE@ABU0@@Z"
568 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?a@T@@QAEXXZ"
571 // M32-DAG: @"?b@T@@2HA" = external dso_local global i32
574 // M32-DAG: @"?c@T@@2HA" = dso_local dllexport global i32 0, align 4
580 // Export template class with static member variable
581 // MSC-DAG: @"?StaticClassVarExpTmplClass@?$TmplClass@H@@2HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
582 // GNU-DAG: @_ZN9TmplClassIiE26StaticClassVarExpTmplClassE = weak_odr dso_local dllexport global i32 0, comdat, align 4
584 struct __declspec(dllexport
) TmplClass
586 static T StaticClassVarExpTmplClass
;
590 T TmplClass
<T
>::StaticClassVarExpTmplClass
;
592 // Export a definition of a template function.
593 // MSC-DAG: define weak_odr dso_local dllexport i32 @"??$TypeFunTmpl@H@@YAHH@Z"
594 // GNU-DAG: define weak_odr dso_local dllexport i32 @_Z11TypeFunTmplIiET_S0_
596 T
__declspec(dllexport
) TypeFunTmpl(T t
) { return t
+ t
; }
598 // Instantiate the exported template class and the exported template function.
599 int useExportedTmplStaticAndFun()
601 return TmplClass
<int>::StaticClassVarExpTmplClass
+ TypeFunTmpl
<int>(10);
604 template <typename T
> struct __declspec(dllexport
) U
{ void foo() {} };
605 struct __declspec(dllexport
) V
: public U
<int> { };
606 // U<int>'s assignment operator is emitted.
607 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"??4?$U@H@@QAEAAU0@ABU0@@Z"
609 struct __declspec(dllexport
) W
{ virtual void foo(); };
612 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0W@@QAE@XZ"
614 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0W@@QAE@ABU0@@Z"
616 // M32-DAG: [[W_VTABLE:@.*]] = private unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ptr @"??_R4W@@6B@", ptr @"?foo@W@@UAEXXZ"] }, comdat($"??_7W@@6B@")
617 // M32-DAG: @"??_7W@@6B@" = dllexport unnamed_addr alias ptr, getelementptr inbounds ({ [2 x ptr] }, ptr [[W_VTABLE]], i32 0, i32 0, i32 1)
618 // G32-DAG: @_ZTV1W = dso_local dllexport unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1W, ptr @_ZN1W3fooEv] }
620 struct __declspec(dllexport
) X
: public virtual W
{};
622 // M32-DAG: @"??_8X@@7B@" = weak_odr dllexport unnamed_addr constant [2 x i32] [i32 0, i32 4]
624 struct __declspec(dllexport
) Y
{
625 // Move assignment operator:
626 // MSVC2015-DAG: define weak_odr dso_local dllexport {{.+}} @"??4Y@@Q{{.+}}@$$Q{{.+}}@@Z"
627 // MSVC2013-DAG: define weak_odr dso_local dllexport {{.+}} @"??4Y@@Q{{.+}}0@A{{.+}}0@@Z"
632 struct __declspec(dllexport
) Z
{ virtual ~Z() {} };
633 // The scalar deleting dtor does not get exported:
634 // M32-DAG: define linkonce_odr dso_local x86_thiscallcc ptr @"??_GZ@@UAEPAXI@Z"
637 // The user-defined dtor does get exported:
638 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??1Z@@UAE@XZ"
640 namespace UseDtorAlias
{
641 struct __declspec(dllexport
) A
{ ~A(); };
642 struct __declspec(dllexport
) B
: A
{ ~B(); };
645 // Emit a alias definition of B's constructor.
646 // M32-DAG: @"??1B@UseDtorAlias@@QAE@XZ" = dso_local dllexport unnamed_addr alias {{.*}} @"??1A@UseDtorAlias@@QAE@XZ"
649 struct __declspec(dllexport
) DefaultedCtorsDtors
{
650 DefaultedCtorsDtors() = default;
651 // M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0DefaultedCtorsDtors@@QAE@XZ"
652 ~DefaultedCtorsDtors() = default;
653 // M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??1DefaultedCtorsDtors@@QAE@XZ"
656 // Export defaulted member function definitions declared inside class.
657 struct __declspec(dllexport
) ExportDefaultedInclassDefs
{
658 ExportDefaultedInclassDefs() = default;
659 // M32VS2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ExportDefaultedInclassDefs@@QAE@XZ"(ptr returned %this)
660 // M64VS2013-DAG: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@XZ"(ptr returned %this)
661 // M32VS2015-NOT: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ExportDefaultedInclassDefs@@QAE@XZ"(ptr returned %this)
662 // M64VS2015-NOT: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@XZ"(ptr returned %this)
664 ~ExportDefaultedInclassDefs() = default;
665 // M32VS2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??1ExportDefaultedInclassDefs@@QAE@XZ"(ptr %this)
666 // M64VS2013-DAG: define weak_odr dso_local dllexport void @"??1ExportDefaultedInclassDefs@@QEAA@XZ"(ptr %this)
667 // M32VS2015-NOT: define weak_odr dso_local dllexport x86_thiscallcc void @"??1ExportDefaultedInclassDefs@@QAE@XZ"(ptr %this)
668 // M64VS2015-NOT: define weak_odr dso_local dllexport void @"??1ExportDefaultedInclassDefs@@QEAA@XZ"(ptr %this)
670 ExportDefaultedInclassDefs(const ExportDefaultedInclassDefs
&) = default;
671 // M32VS2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ExportDefaultedInclassDefs@@QAE@ABU0@@Z"(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}))
672 // M64VS2013-DAG: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@AEBU0@@Z"(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}))
673 // M32VS2015-NOT: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ExportDefaultedInclassDefs@@QAE@ABU0@@Z"(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}))
674 // M64VS2015-NOT: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@AEBU0@@Z"(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}))
676 ExportDefaultedInclassDefs
& operator=(const ExportDefaultedInclassDefs
&) = default;
677 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"??4ExportDefaultedInclassDefs@@QAEAAU0@ABU0@@Z"(ptr {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0)
678 // M64-DAG: define weak_odr dso_local dllexport nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"??4ExportDefaultedInclassDefs@@QEAAAEAU0@AEBU0@@Z"(ptr {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %0)
681 namespace ReferencedInlineMethodInNestedClass
{
682 struct __declspec(dllexport
) S
{
691 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?foo@S@ReferencedInlineMethodInNestedClass@@QAEXXZ"
692 // M32-DAG: define linkonce_odr dso_local x86_thiscallcc void @"?bar@T@S@ReferencedInlineMethodInNestedClass@@QAEXXZ"
695 // MS ignores DLL attributes on partial specializations.
696 template <typename T
> struct PartiallySpecializedClassTemplate
{};
697 template <typename T
> struct __declspec(dllexport
) PartiallySpecializedClassTemplate
<T
*> { void f(); };
698 template <typename T
> void PartiallySpecializedClassTemplate
<T
*>::f() {}
699 USEMEMFUNC(PartiallySpecializedClassTemplate
<void*>, f
);
700 // M32-DAG: define linkonce_odr dso_local x86_thiscallcc void @"?f@?$PartiallySpecializedClassTemplate@PAX@@QAEXXZ"
701 // G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv
703 // Attributes on explicit specializations are honored.
704 template <typename T
> struct ExplicitlySpecializedClassTemplate
{};
705 template <> struct __declspec(dllexport
) ExplicitlySpecializedClassTemplate
<void*> { void f(); };
706 void ExplicitlySpecializedClassTemplate
<void*>::f() {}
707 USEMEMFUNC(ExplicitlySpecializedClassTemplate
<void*>, f
);
708 // M32-DAG: define dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitlySpecializedClassTemplate@PAX@@QAEXXZ"
709 // G32-DAG: define dso_local dllexport x86_thiscallcc void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv
711 // MS inherits DLL attributes to partial specializations.
712 template <typename T
> struct __declspec(dllexport
) PartiallySpecializedExportedClassTemplate
{};
713 template <typename T
> struct PartiallySpecializedExportedClassTemplate
<T
*> { void f() {} };
714 USEMEMFUNC(PartiallySpecializedExportedClassTemplate
<void*>, f
);
715 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$PartiallySpecializedExportedClassTemplate@PAX@@QAEXXZ"
716 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN41PartiallySpecializedExportedClassTemplateIPvE1fEv
718 // MS ignores DLL attributes on partial specializations; inheritance still works though.
719 template <typename T
> struct __declspec(dllexport
) PartiallySpecializedExportedClassTemplate2
{};
720 template <typename T
> struct __declspec(dllimport
) PartiallySpecializedExportedClassTemplate2
<T
*> { void f(); };
721 template <typename T
> void PartiallySpecializedExportedClassTemplate2
<T
*>::f() {}
722 USEMEMFUNC(PartiallySpecializedExportedClassTemplate2
<void*>, f
);
723 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$PartiallySpecializedExportedClassTemplate2@PAX@@QAEXXZ"
724 // G32-DAG: declare dllimport x86_thiscallcc void @_ZN42PartiallySpecializedExportedClassTemplate2IPvE1fEv
726 // Attributes on the instantiation take precedence over attributes on the template.
727 template <typename T
> struct __declspec(dllimport
) ExplicitlyInstantiatedWithDifferentAttr
{ void f() {} };
728 template struct __declspec(dllexport
) ExplicitlyInstantiatedWithDifferentAttr
<int>;
729 USEMEMFUNC(ExplicitlyInstantiatedWithDifferentAttr
<int>, f
);
730 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitlyInstantiatedWithDifferentAttr@H@@QAEXXZ"
732 // Don't create weak dllexport aliases. (PR21373)
733 struct NonExportedBaseClass
{
734 virtual ~NonExportedBaseClass();
736 NonExportedBaseClass::~NonExportedBaseClass() {}
738 struct __declspec(dllexport
) ExportedDerivedClass
: NonExportedBaseClass
{};
739 // M32-DAG: weak_odr dso_local dllexport x86_thiscallcc void @"??1ExportedDerivedClass@@UAE@XZ"
741 // Do not assert about generating code for constexpr functions twice during explicit instantiation (PR21718).
742 template <typename T
> struct ExplicitInstConstexprMembers
{
743 // Copy assignment operator
744 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align 1 dereferenceable(1) ptr @"??4?$ExplicitInstConstexprMembers@X@@QAEAAU0@ABU0@@Z"
746 constexpr ExplicitInstConstexprMembers() {}
747 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$ExplicitInstConstexprMembers@X@@QAE@XZ"
749 ExplicitInstConstexprMembers(const ExplicitInstConstexprMembers
&) = default;
750 // M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$ExplicitInstConstexprMembers@X@@QAE@ABU0@@Z"
752 constexpr int f() const { return 42; }
753 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc i32 @"?f@?$ExplicitInstConstexprMembers@X@@QBEHXZ"
755 template struct __declspec(dllexport
) ExplicitInstConstexprMembers
<void>;
757 template <typename T
> struct ExplicitInstantiationDeclTemplate
{ void f() {} };
758 extern template struct __declspec(dllexport
) ExplicitInstantiationDeclTemplate
<int>;
759 USEMEMFUNC(ExplicitInstantiationDeclTemplate
<int>, f
);
760 // M32-DAG: {{declare|define available_externally}} dso_local x86_thiscallcc void @"?f@?$ExplicitInstantiationDeclTemplate@H@@QAEXXZ"
762 template <typename T
> struct __declspec(dllexport
) ExplicitInstantiationDeclExportedTemplate
{ void f() {} };
763 extern template struct ExplicitInstantiationDeclExportedTemplate
<int>;
764 USEMEMFUNC(ExplicitInstantiationDeclExportedTemplate
<int>, f
);
765 // M32-DAG: {{declare|define available_externally}} dso_local x86_thiscallcc void @"?f@?$ExplicitInstantiationDeclExportedTemplate@H@@QAEXXZ"
767 template <typename T
> struct ExplicitInstantiationDeclExportedDefTemplate
{ void f() {} ExplicitInstantiationDeclExportedDefTemplate() {} };
768 extern template struct ExplicitInstantiationDeclExportedDefTemplate
<int>;
769 template struct __declspec(dllexport
) ExplicitInstantiationDeclExportedDefTemplate
<int>;
770 USEMEMFUNC(ExplicitInstantiationDeclExportedDefTemplate
<int>, f
);
771 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAEXXZ"
772 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAE@XZ"
773 // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv
775 template <typename T
> struct ImplicitInstantiationExportedExplicitInstantiationDefTemplate
{ virtual void f() {} };
776 ImplicitInstantiationExportedExplicitInstantiationDefTemplate
<int> ImplicitInstantiationExportedExplicitInstantiationDefTemplateInstance
;
777 template struct __declspec(dllexport
) ImplicitInstantiationExportedExplicitInstantiationDefTemplate
<int>;
778 USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefTemplate
<int>, f
);
779 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ImplicitInstantiationExportedExplicitInstantiationDefTemplate@H@@UAEXXZ"
780 // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN61ImplicitInstantiationExportedExplicitInstantiationDefTemplateIiE1fEv
782 template <typename T
> struct __declspec(dllexport
) ImplicitInstantiationExplicitInstantiationDefExportedTemplate
{ virtual void f() {} };
783 ImplicitInstantiationExplicitInstantiationDefExportedTemplate
<int> ImplicitInstantiationExplicitInstantiationDefExportedTemplateInstance
;
784 template struct ImplicitInstantiationExplicitInstantiationDefExportedTemplate
<int>;
785 USEMEMFUNC(ImplicitInstantiationExplicitInstantiationDefExportedTemplate
<int>, f
);
786 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@UAEXXZ"
787 // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN61ImplicitInstantiationExplicitInstantiationDefExportedTemplateIiE1fEv
789 template <typename T
> struct __declspec(dllexport
) ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate
{ virtual void f() {} };
790 ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate
<int> ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateInstance
;
791 template struct __declspec(dllexport
) ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate
<int>;
792 USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate
<int>, f
);
793 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate@H@@UAEXXZ"
794 // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN69ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateIiE1fEv
796 namespace { struct InternalLinkageType
{}; }
797 struct __declspec(dllexport
) PR23308
{
798 void f(InternalLinkageType
*);
800 void PR23308::f(InternalLinkageType
*) {}
801 long use(PR23308
* p
) { p
->f(nullptr); }
802 // M32-DAG: define internal x86_thiscallcc void @"?f@PR23308@@QAEXPAUInternalLinkageType@?A0x{{[^@]*}}@@@Z"
804 template <typename T
> struct PR23770BaseTemplate
{ void f() {} };
805 template <typename T
> struct PR23770DerivedTemplate
: PR23770BaseTemplate
<int> {};
806 extern template struct PR23770DerivedTemplate
<int>;
807 template struct __declspec(dllexport
) PR23770DerivedTemplate
<int>;
808 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$PR23770BaseTemplate@H@@QAEXXZ"
810 namespace InClassInits
{
812 struct __declspec(dllexport
) S
{
815 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0S@InClassInits@@QAE@XZ"
817 // dllexport an already instantiated class template.
818 template <typename T
> struct Base
{
822 struct __declspec(dllexport
) T
: Base
<int> { };
823 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$Base@H@InClassInits@@QAE@XZ"
825 struct A
{ A(int); };
826 struct __declspec(dllexport
) U
{
827 // Class with both default constructor closure and in-class initializer.
831 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0U@InClassInits@@QAE@UA@1@@Z"
834 template <typename T
> struct Base
{
837 struct S
: Base
<int> {};
838 // The already instantiated Base<int> becomes dllexported below, but the
839 // in-class initializer for Base<>::x still hasn't been parsed, so emitting
840 // the default ctor must still be delayed.
841 struct __declspec(dllexport
) T
: Base
<int> {};
843 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$Base@H@Evil@InClassInits@@QAE@XZ"
845 template <typename T
> struct Foo
{};
846 template <typename T
> struct Bar
{
847 Bar
<T
> &operator=(Foo
<T
>) {}
849 struct __declspec(dllexport
) Baz
{
852 // After parsing Baz, in ActOnFinishCXXNonNestedClass we would synthesize
853 // Baz's operator=, causing instantiation of Foo<int> after which
854 // ActOnFinishCXXNonNestedClass is called, and we would bite our own tail.
855 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align 1 dereferenceable(1) ptr @"??4Baz@InClassInits@@QAEAAU01@ABU01@@Z"
857 // Trying to define the explicitly defaulted ctor must be delayed until the
858 // in-class initializer for x has been processed.
860 __declspec(dllexport
) PR40006() = default;
863 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0PR40006@InClassInits@@QAE@XZ"
866 // Delay emitting the method also past the instantiation of Tmpl<Inner>, i.e.
867 // until the top-level class Outer is completely finished.
868 template<typename
> struct Tmpl
{};
871 __declspec(dllexport
) Inner() = default;
876 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0Inner@Outer@pr40006@InClassInits@@QAE@XZ"
879 // PR42857: Clang would try to emit the non-trivial explicitly defaulted
880 // dllexport ctor twice when doing an explicit instantiation definition.
881 struct Qux
{ Qux(); };
882 template <typename T
> struct PR42857
{ __declspec(dllexport
) PR42857() = default; Qux q
; };
883 template struct PR42857
<int>;
884 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$PR42857@H@InClassInits@@QAE@XZ"
888 // We had an issue where instantiating A would force emission of B's delayed
891 template <typename T
> struct A
{ };
892 struct __declspec(dllexport
) B
{
896 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FB@pr26490@@QAEXXZ"
899 // dllexport trumps dllimport on an explicit instantiation.
900 template <typename T
> struct ExplicitInstantiationTwoAttributes
{ void f() {} };
901 template struct __declspec(dllexport
) __declspec(dllimport
) ExplicitInstantiationTwoAttributes
<int>;
902 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ"
905 // Specializations of exported class template member functions get exported.
906 template <typename
> struct __declspec(dllexport
) ExportedClassTemplate
{ void foo(); };
907 template<> void ExportedClassTemplate
<int>::foo() {}
908 template struct ExportedClassTemplate
<int>;
909 // M32-DAG: define dso_local dllexport x86_thiscallcc void @"?foo@?$ExportedClassTemplate@H@pr34849@@QAEXXZ"
911 // Specializations of exported class member template functions do not get exported.
912 struct __declspec(dllexport
) ExportedClass
{ template <typename
> void bar() ; };
913 template<> void ExportedClass::bar
<int>() {}
914 // M32-DAG: define dso_local x86_thiscallcc void @"??$bar@H@ExportedClass@pr34849@@QAEXXZ"
915 template <typename
> struct __declspec(dllexport
) ExportedClassTemplate2
{ template <typename
> void baz(); };
916 template<> template<> void ExportedClassTemplate2
<int>::baz
<int>() {}
917 // M32-DAG: define dso_local x86_thiscallcc void @"??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
923 template <typename
> struct S
{
927 template struct __declspec(dllexport
) S
<int>;
928 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$S@H@pr47683@@QAE@XZ"
930 template <typename
> struct T
{
934 extern template struct T
<int>;
935 template struct __declspec(dllexport
) T
<int>;
936 // Don't assert about multiple codegen for explicitly defaulted method in explicit instantiation def.
937 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$T@H@pr47683@@QAE@XZ"
939 template <typename
> struct U
{
943 template <typename T
> U
<T
>::U() = default;
944 extern template struct U
<int>;
945 template struct __declspec(dllexport
) U
<int>;
946 // Same as T, but with out-of-line ctor.
947 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$U@H@pr47683@@QAE@XZ"
950 //===----------------------------------------------------------------------===//
951 // Classes with template base classes
952 //===----------------------------------------------------------------------===//
954 template <typename T
> struct ClassTemplate
{ void func(); };
955 template <typename T
> void ClassTemplate
<T
>::func() {}
956 template <typename T
> struct __declspec(dllexport
) ExportedClassTemplate
{ void func(); };
957 template <typename T
> void ExportedClassTemplate
<T
>::func() {}
958 template <typename T
> struct __declspec(dllimport
) ImportedClassTemplate
{ void func(); };
959 template <typename T
> void ImportedClassTemplate
<T
>::func() {}
961 template <typename T
> struct ExplicitlySpecializedTemplate
{ void func() {} };
962 template <> struct ExplicitlySpecializedTemplate
<int> { void func(); };
963 void ExplicitlySpecializedTemplate
<int>::func() {}
964 template <typename T
> struct ExplicitlyExportSpecializedTemplate
{ void func() {} };
965 template <> struct __declspec(dllexport
) ExplicitlyExportSpecializedTemplate
<int> { void func(); };
966 void ExplicitlyExportSpecializedTemplate
<int>::func() {}
967 template <typename T
> struct ExplicitlyImportSpecializedTemplate
{ void func(); };
968 template <> struct __declspec(dllimport
) ExplicitlyImportSpecializedTemplate
<int> { void func(); };
970 template <typename T
> struct ExplicitlyInstantiatedTemplate
{ void func(); };
971 template <typename T
> void ExplicitlyInstantiatedTemplate
<T
>::func() {}
972 template struct ExplicitlyInstantiatedTemplate
<int>;
973 template <typename T
> struct ExplicitlyExportInstantiatedTemplate
{ void func(); };
974 template <typename T
> void ExplicitlyExportInstantiatedTemplate
<T
>::func() {}
975 template struct __declspec(dllexport
) ExplicitlyExportInstantiatedTemplate
<int>;
976 template <typename T
> struct ExplicitlyImportInstantiatedTemplate
{ void func(); };
977 template struct __declspec(dllimport
) ExplicitlyImportInstantiatedTemplate
<int>;
980 // MS: ClassTemplate<int> gets exported.
981 struct __declspec(dllexport
) DerivedFromTemplate
: public ClassTemplate
<int> {};
982 USEMEMFUNC(DerivedFromTemplate
, func
)
983 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ClassTemplate@H@@QAEXXZ"
984 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN13ClassTemplateIiE4funcEv
985 // PS-DAG: define weak_odr dllexport void @_ZN13ClassTemplateIiE4funcEv
987 // ExportedTemplate is explicitly exported.
988 struct __declspec(dllexport
) DerivedFromExportedTemplate
: public ExportedClassTemplate
<int> {};
989 USEMEMFUNC(DerivedFromExportedTemplate
, func
)
990 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ExportedClassTemplate@H@@QAEXXZ"
991 // G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @_ZN21ExportedClassTemplateIiE4funcEv
992 // PS-DAG: define weak_odr dllexport void @_ZN21ExportedClassTemplateIiE4funcEv
994 // ImportedClassTemplate is explicitly imported.
995 struct __declspec(dllexport
) DerivedFromImportedTemplate
: public ImportedClassTemplate
<int> {};
996 USEMEMFUNC(DerivedFromImportedTemplate
, func
)
997 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"?func@?$ImportedClassTemplate@H@@QAEXXZ"
998 // G32-DAG: declare dllimport x86_thiscallcc void @_ZN21ImportedClassTemplateIiE4funcEv
999 // PS-DAG: declare dllimport void @_ZN21ImportedClassTemplateIiE4funcEv
1001 // Base class already implicitly instantiated without dll attribute.
1002 struct DerivedFromTemplateD
: public ClassTemplate
<double> {};
1003 struct __declspec(dllexport
) DerivedFromTemplateD2
: public ClassTemplate
<double> {};
1004 USEMEMFUNC(DerivedFromTemplateD2
, func
)
1005 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ClassTemplate@N@@QAEXXZ"
1006 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN13ClassTemplateIdE4funcEv
1007 // PS-DAG: define weak_odr dllexport void @_ZN13ClassTemplateIdE4funcEv
1009 // MS: Base class already instantiated with different dll attribute.
1010 struct __declspec(dllimport
) DerivedFromTemplateB
: public ClassTemplate
<bool> {};
1011 struct __declspec(dllexport
) DerivedFromTemplateB2
: public ClassTemplate
<bool> {};
1012 USEMEMFUNC(DerivedFromTemplateB2
, func
)
1013 // M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"?func@?$ClassTemplate@_N@@QAEXXZ"
1014 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN13ClassTemplateIbE4funcEv
1015 // PS-DAG: declare dllimport void @_ZN13ClassTemplateIbE4funcEv
1017 // Base class already specialized without dll attribute.
1018 struct __declspec(dllexport
) DerivedFromExplicitlySpecializedTemplate
: public ExplicitlySpecializedTemplate
<int> {};
1019 USEMEMFUNC(DerivedFromExplicitlySpecializedTemplate
, func
)
1020 // M32-DAG: define dso_local x86_thiscallcc void @"?func@?$ExplicitlySpecializedTemplate@H@@QAEXXZ"
1021 // G32-DAG: define dso_local x86_thiscallcc void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv
1022 // PS-DAG: define dso_local void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv
1024 // Base class alredy specialized with export attribute.
1025 struct __declspec(dllexport
) DerivedFromExplicitlyExportSpecializedTemplate
: public ExplicitlyExportSpecializedTemplate
<int> {};
1026 USEMEMFUNC(DerivedFromExplicitlyExportSpecializedTemplate
, func
)
1027 // M32-DAG: define dso_local dllexport x86_thiscallcc void @"?func@?$ExplicitlyExportSpecializedTemplate@H@@QAEXXZ"
1028 // G32-DAG: define dso_local dllexport x86_thiscallcc void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv
1029 // PS-DAG: define dso_local dllexport void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv
1031 // Base class already specialized with import attribute.
1032 struct __declspec(dllexport
) DerivedFromExplicitlyImportSpecializedTemplate
: public ExplicitlyImportSpecializedTemplate
<int> {};
1033 USEMEMFUNC(DerivedFromExplicitlyImportSpecializedTemplate
, func
)
1034 // M32-DAG: declare dllimport x86_thiscallcc void @"?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ"
1035 // G32-DAG: declare dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
1036 // PS-DAG: declare dllimport void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv
1038 // Base class already instantiated without dll attribute.
1039 struct __declspec(dllexport
) DerivedFromExplicitlyInstantiatedTemplate
: public ExplicitlyInstantiatedTemplate
<int> {};
1040 USEMEMFUNC(DerivedFromExplicitlyInstantiatedTemplate
, func
)
1041 // M32-DAG: define weak_odr dso_local x86_thiscallcc void @"?func@?$ExplicitlyInstantiatedTemplate@H@@QAEXXZ"
1042 // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv
1043 // PS-DAG: define weak_odr void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv
1045 // Base class already instantiated with export attribute.
1046 struct __declspec(dllexport
) DerivedFromExplicitlyExportInstantiatedTemplate
: public ExplicitlyExportInstantiatedTemplate
<int> {};
1047 USEMEMFUNC(DerivedFromExplicitlyExportInstantiatedTemplate
, func
)
1048 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ExplicitlyExportInstantiatedTemplate@H@@QAEXXZ"
1049 // G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv
1050 // PS-DAG: define weak_odr dllexport void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv
1052 // Base class already instantiated with import attribute.
1053 struct __declspec(dllexport
) DerivedFromExplicitlyImportInstantiatedTemplate
: public ExplicitlyImportInstantiatedTemplate
<int> {};
1054 USEMEMFUNC(DerivedFromExplicitlyImportInstantiatedTemplate
, func
)
1055 // M32-DAG: declare dllimport x86_thiscallcc void @"?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ"
1056 // G32-DAG: declare dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
1057 // PS-DAG: declare dllimport void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv
1059 // MS: A dll attribute propagates through multiple levels of instantiation.
1060 template <typename T
> struct TopClass
{ void func() {} };
1061 template <typename T
> struct MiddleClass
: public TopClass
<T
> { };
1062 struct __declspec(dllexport
) BottomClass
: public MiddleClass
<int> { };
1063 USEMEMFUNC(BottomClass
, func
)
1064 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$TopClass@H@@QAEXXZ"
1065 // G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN8TopClassIiE4funcEv
1066 // PS-DAG: define weak_odr dllexport void @_ZN8TopClassIiE4funcEv
1068 template <typename T
> struct ExplicitInstantiationDeclTemplateBase
{ void func() {} };
1069 extern template struct ExplicitInstantiationDeclTemplateBase
<int>;
1070 struct __declspec(dllexport
) DerivedFromExplicitInstantiationDeclTemplateBase
: public ExplicitInstantiationDeclTemplateBase
<int> {};
1071 template struct ExplicitInstantiationDeclTemplateBase
<int>;
1072 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ"
1073 // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
1074 // PS-DAG: define weak_odr dllexport void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv
1077 struct LayerSelectionBound
;
1078 template <typename
> struct Selection
{};
1079 typedef Selection
<LayerSelectionBound
> LayerSelection
;
1081 struct __declspec(dllexport
) LayerTreeImpl
{
1082 struct __declspec(dllexport
) ElementLayers
{
1083 LayerImpl
*main
= nullptr;
1087 // M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ElementLayers@LayerTreeImpl@@QAE@XZ"
1088 // M64-DAG: define weak_odr dso_local dllexport ptr @"??0ElementLayers@LayerTreeImpl@@QEAA@XZ"
1091 // Make sure dll attribute are inherited by static locals also in template
1093 template <typename
> struct __declspec(dllexport
) S
{ int foo() { static int x
; return x
++; } };
1094 int foo() { S
<int> s
; return s
.foo(); }
1095 // MSC-DAG: @"?x@?{{1|2}}??foo@?$S@H@pr39496@@Q{{[A-Z]*}}HXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
1097 template <typename
> struct T
{ int foo() { static int x
; return x
++; } };
1098 template struct __declspec(dllexport
) T
<int>;
1099 // MSC-DAG: @"?x@?{{1|2}}??foo@?$T@H@pr39496@@Q{{[A-Z]*}}HXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4
1102 class __declspec(dllexport
) ACE_Shared_Object
{
1104 virtual ~ACE_Shared_Object();
1106 class __declspec(dllexport
) ACE_Service_Object
: public ACE_Shared_Object
{};
1107 // Implicit move constructor declaration.
1108 // MSVC2015-DAG: define weak_odr dso_local dllexport {{.+}}ACE_Service_Object@@Q{{.+}}@$$Q
1109 // The declarations should not be exported.
1110 // MSVC2013-NOT: define weak_odr dso_local dllexport {{.+}}ACE_Service_Object@@Q{{.+}}@$$Q