| 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 |
| 3 |
|
| 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 |
| 6 |
|
| 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 i686-pc-cygwin -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck -allow-deprecated-dag-overlap --check-prefix=GNU --check-prefix=C32 %s |
| 10 |
// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-pc-cygwin -emit-llvm -std=c++1y -fno-threadsafe-statics -fms-extensions -O0 -o - %s -w | FileCheck -allow-deprecated-dag-overlap --check-prefix=GNU %s |
| 11 |
// 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 |
| 12 |
// 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 |
| 13 |
|
| 14 |
// Helper structs to make templates more expressive. |
| 15 |
struct ImplicitInst_Exported {}; |
| 16 |
struct ExplicitDecl_Exported {}; |
| 17 |
struct ExplicitInst_Exported {}; |
| 18 |
struct ExplicitSpec_Exported {}; |
| 19 |
struct ExplicitSpec_Def_Exported {}; |
| 20 |
struct ExplicitSpec_InlineDef_Exported {}; |
| 21 |
struct ExplicitSpec_NotExported {}; |
| 22 |
struct External { int v; }; |
| 23 |
|
| 24 |
#define JOIN2(x, y) x##y |
| 25 |
#define JOIN(x, y) JOIN2(x, y) |
| 26 |
#define UNIQ(name) JOIN(name, __LINE__) |
| 27 |
#define USEVAR(var) int UNIQ(use)() { return var; } |
| 28 |
#define USE(func) void UNIQ(use)() { func(); } |
| 29 |
#define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; } |
| 30 |
#define INSTVAR(var) template int var; |
| 31 |
#define INST(func) template void func(); |
| 32 |
|
| 33 |
// The vftable for struct W is comdat largest because we have RTTI. |
| 34 |
// M32-DAG: $"??_7W@@6B@" = comdat largest |
| 35 |
|
| 36 |
// M32-DAG: $"?smember@?$Base@H@PR32992@@0HA" = comdat any |
| 37 |
|
| 38 |
|
| 39 |
//===----------------------------------------------------------------------===// |
| 40 |
// Globals |
| 41 |
//===----------------------------------------------------------------------===// |
| 42 |
|
| 43 |
// Declarations are not exported. |
| 44 |
// MSC-NOT: @"?ExternGlobalDecl@@3HA" |
| 45 |
// GNU-NOT: @ExternGlobalDecl |
| 46 |
__declspec(dllexport) extern int ExternGlobalDecl; |
| 47 |
|
| 48 |
// M64-DAG: @__ImageBase = external dso_local constant i8 |
| 49 |
|
| 50 |
// GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external global |
| 51 |
|
| 52 |
// dllexport implies a definition. |
| 53 |
// MSC-DAG: @"?GlobalDef@@3HA" = dso_local dllexport global i32 0, align 4 |
| 54 |
// GNU-DAG: @GlobalDef = dso_local dllexport global i32 0, align 4 |
| 55 |
__declspec(dllexport) int GlobalDef; |
| 56 |
|
| 57 |
// Export definition. |
| 58 |
// MSC-DAG: @"?GlobalInit1@@3HA" = dso_local dllexport global i32 1, align 4 |
| 59 |
// GNU-DAG: @GlobalInit1 = dso_local dllexport global i32 1, align 4 |
| 60 |
__declspec(dllexport) int GlobalInit1 = 1; |
| 61 |
|
| 62 |
// MSC-DAG: @"?GlobalInit2@@3HA" = dso_local dllexport global i32 1, align 4 |
| 63 |
// GNU-DAG: @GlobalInit2 = dso_local dllexport global i32 1, align 4 |
| 64 |
int __declspec(dllexport) GlobalInit2 = 1; |
| 65 |
|
| 66 |
// Declare, then export definition. |
| 67 |
// MSC-DAG: @"?GlobalDeclInit@@3HA" = dso_local dllexport global i32 1, align 4 |
| 68 |
// GNU-DAG: @GlobalDeclInit = dso_local dllexport global i32 1, align 4 |
| 69 |
__declspec(dllexport) extern int GlobalDeclInit; |
| 70 |
int GlobalDeclInit = 1; |
| 71 |
|
| 72 |
// Redeclarations |
| 73 |
// MSC-DAG: @"?GlobalRedecl1@@3HA" = dso_local dllexport global i32 0, align 4 |
| 74 |
// GNU-DAG: @GlobalRedecl1 = dso_local dllexport global i32 0, align 4 |
| 75 |
__declspec(dllexport) extern int GlobalRedecl1; |
| 76 |
__declspec(dllexport) int GlobalRedecl1; |
| 77 |
|
| 78 |
// MSC-DAG: @"?GlobalRedecl2@@3HA" = dso_local dllexport global i32 0, align 4 |
| 79 |
// GNU-DAG: @GlobalRedecl2 = dso_local dllexport global i32 0, align 4 |
| 80 |
__declspec(dllexport) extern int GlobalRedecl2; |
| 81 |
int GlobalRedecl2; |
| 82 |
|
| 83 |
// MSC-DAG: @"?ExternalGlobal@ns@@3HA" = dso_local dllexport global i32 0, align 4 |
| 84 |
// GNU-DAG: @_ZN2ns14ExternalGlobalE = dso_local dllexport global i32 0, align 4 |
| 85 |
namespace ns { __declspec(dllexport) int ExternalGlobal; } |
| 86 |
|
| 87 |
// MSC-DAG: @"?ExternalAutoTypeGlobal@@3UExternal@@A" = dso_local dllexport global %struct.External zeroinitializer, align 4 |
| 88 |
// GNU-DAG: @ExternalAutoTypeGlobal = dso_local dllexport global %struct.External zeroinitializer, align 4 |
| 89 |
__declspec(dllexport) auto ExternalAutoTypeGlobal = External(); |
| 90 |
|
| 91 |
int f(); |
| 92 |
// MSC-DAG: @"?x@?1??nonInlineStaticLocalsFunc@@YAHXZ@4HA" = internal {{(unnamed_addr )*}}global i32 0 |
| 93 |
// MSC-DAG: @"?$S1@?1??nonInlineStaticLocalsFunc@@YAHXZ@4IA" = internal {{(unnamed_addr )*}}global i32 0 |
| 94 |
int __declspec(dllexport) nonInlineStaticLocalsFunc() { |
| 95 |
static int x = f(); |
| 96 |
return x++; |
| 97 |
}; |
| 98 |
|
| 99 |
// MSC-DAG: @"?x@?1??inlineStaticLocalsFunc@@YAHXZ@4HA" = weak_odr dso_local dllexport global i32 0, comdat |
| 100 |
// MSC-DAG: @"??_B?1??inlineStaticLocalsFunc@@YAHXZ@51" = weak_odr dllexport global i32 0, comdat |
| 101 |
// Note: MinGW doesn't seem to export the static local here. |
| 102 |
inline int __declspec(dllexport) inlineStaticLocalsFunc() { |
| 103 |
static int x = f(); |
| 104 |
return x++; |
| 105 |
} |
| 106 |
|
| 107 |
namespace PR32992 { |
| 108 |
// Static data members of a instantiated base class should be exported. |
| 109 |
template <class T> |
| 110 |
class Base { |
| 111 |
virtual void myfunc() {} |
| 112 |
static int smember; |
| 113 |
}; |
| 114 |
// MSC-DAG: @"?smember@?$Base@H@PR32992@@0HA" = weak_odr dso_local dllexport global i32 77, comdat, align 4 |
| 115 |
template <class T> int Base<T>::smember = 77; |
| 116 |
template <class T> |
| 117 |
class __declspec(dllexport) Derived2 : Base<T> { |
| 118 |
void myfunc() {} |
| 119 |
}; |
| 120 |
class Derived : public Derived2<int> { |
| 121 |
void myfunc() {} |
| 122 |
}; |
| 123 |
} // namespace PR32992 |
| 124 |
|
| 125 |
namespace PR32992_1 { |
| 126 |
namespace a { enum b { c }; } |
| 127 |
template <typename> class d { |
| 128 |
static constexpr a::b e = a::c; |
| 129 |
}; |
| 130 |
namespace f { |
| 131 |
template <typename g = int> class h : d<g> {}; |
| 132 |
} |
| 133 |
using f::h; |
| 134 |
class __declspec(dllexport) i : h<> {}; |
| 135 |
} |
| 136 |
|
| 137 |
//===----------------------------------------------------------------------===// |
| 138 |
// Variable templates |
| 139 |
//===----------------------------------------------------------------------===// |
| 140 |
|
| 141 |
// Declarations are not exported. |
| 142 |
|
| 143 |
// MSC-DAG: @"??$VarTmplImplicitDef@UImplicitInst_Exported@@@@3HA" = external dso_local global |
| 144 |
// GNU-DAG: @_Z18VarTmplImplicitDefI21ImplicitInst_ExportedE = external global |
| 145 |
template<typename T> __declspec(dllexport) extern int VarTmplImplicitDef; |
| 146 |
USEVAR(VarTmplImplicitDef<ImplicitInst_Exported>) |
| 147 |
|
| 148 |
// Export definition. |
| 149 |
// MSC-DAG: @"??$VarTmplInit1@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 150 |
// GNU-DAG: @_Z12VarTmplInit1I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 151 |
template<typename T> __declspec(dllexport) int VarTmplInit1 = 1; |
| 152 |
INSTVAR(VarTmplInit1<ExplicitInst_Exported>) |
| 153 |
|
| 154 |
// MSC-DAG: @"??$VarTmplInit2@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 155 |
// GNU-DAG: @_Z12VarTmplInit2I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 156 |
template<typename T> int __declspec(dllexport) VarTmplInit2 = 1; |
| 157 |
INSTVAR(VarTmplInit2<ExplicitInst_Exported>) |
| 158 |
|
| 159 |
// Declare, then export definition. |
| 160 |
// MSC-DAG: @"??$VarTmplDeclInit@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 161 |
// GNU-DAG: @_Z15VarTmplDeclInitI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 162 |
template<typename T> __declspec(dllexport) extern int VarTmplDeclInit; |
| 163 |
template<typename T> int VarTmplDeclInit = 1; |
| 164 |
INSTVAR(VarTmplDeclInit<ExplicitInst_Exported>) |
| 165 |
|
| 166 |
// Redeclarations |
| 167 |
// MSC-DAG: @"??$VarTmplRedecl1@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 168 |
// GNU-DAG: @_Z14VarTmplRedecl1I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 169 |
template<typename T> __declspec(dllexport) extern int VarTmplRedecl1; |
| 170 |
template<typename T> __declspec(dllexport) int VarTmplRedecl1 = 1; |
| 171 |
INSTVAR(VarTmplRedecl1<ExplicitInst_Exported>) |
| 172 |
|
| 173 |
// MSC-DAG: @"??$VarTmplRedecl2@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 174 |
// GNU-DAG: @_Z14VarTmplRedecl2I21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 175 |
template<typename T> __declspec(dllexport) extern int VarTmplRedecl2; |
| 176 |
template<typename T> int VarTmplRedecl2 = 1; |
| 177 |
INSTVAR(VarTmplRedecl2<ExplicitInst_Exported>) |
| 178 |
|
| 179 |
// MSC-DAG: @"??$ExternalVarTmpl@UExplicitInst_Exported@@@ns@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 180 |
// GNU-DAG: @_ZN2ns15ExternalVarTmplI21ExplicitInst_ExportedEE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 181 |
namespace ns { template<typename T> __declspec(dllexport) int ExternalVarTmpl = 1; } |
| 182 |
INSTVAR(ns::ExternalVarTmpl<ExplicitInst_Exported>) |
| 183 |
|
| 184 |
// MSC-DAG: @"??$ExternalAutoTypeVarTmpl@UExplicitInst_Exported@@@@3UExternal@@A" = weak_odr dso_local dllexport global %struct.External zeroinitializer, comdat, align 4 |
| 185 |
// GNU-DAG: @_Z23ExternalAutoTypeVarTmplI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global %struct.External zeroinitializer, comdat, align 4 |
| 186 |
template<typename T> __declspec(dllexport) auto ExternalAutoTypeVarTmpl = External(); |
| 187 |
template External ExternalAutoTypeVarTmpl<ExplicitInst_Exported>; |
| 188 |
|
| 189 |
|
| 190 |
template<typename T> int VarTmpl = 1; |
| 191 |
template<typename T> __declspec(dllexport) int ExportedVarTmpl = 1; |
| 192 |
|
| 193 |
// Export implicit instantiation of an exported variable template. |
| 194 |
// MSC-DAG: @"??$ExportedVarTmpl@UImplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 195 |
// GNU-DAG: @_Z15ExportedVarTmplI21ImplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 196 |
USEVAR(ExportedVarTmpl<ImplicitInst_Exported>) |
| 197 |
|
| 198 |
// Export explicit instantiation declaration of an exported variable template. |
| 199 |
// MSC-DAG: @"??$ExportedVarTmpl@UImplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 200 |
// GNU-DAG: @_Z15ExportedVarTmplI21ExplicitDecl_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 201 |
extern template int ExportedVarTmpl<ExplicitDecl_Exported>; |
| 202 |
template int ExportedVarTmpl<ExplicitDecl_Exported>; |
| 203 |
|
| 204 |
// Export explicit instantiation definition of an exported variable template. |
| 205 |
// MSC-DAG: @"??$ExportedVarTmpl@UImplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 206 |
// GNU-DAG: @_Z15ExportedVarTmplI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 207 |
template __declspec(dllexport) int ExportedVarTmpl<ExplicitInst_Exported>; |
| 208 |
|
| 209 |
// Export specialization of an exported variable template. |
| 210 |
// MSC-DAG: @"??$ExportedVarTmpl@UExplicitSpec_Exported@@@@3HA" = dso_local dllexport global i32 0, align 4 |
| 211 |
// GNU-DAG: @_Z15ExportedVarTmplI21ExplicitSpec_ExportedE = dso_local dllexport global i32 0, align 4 |
| 212 |
template<> __declspec(dllexport) int ExportedVarTmpl<ExplicitSpec_Exported>; |
| 213 |
|
| 214 |
// MSC-DAG: @"??$ExportedVarTmpl@UExplicitSpec_Def_Exported@@@@3HA" = dso_local dllexport global i32 1, align 4 |
| 215 |
// GNU-DAG: @_Z15ExportedVarTmplI25ExplicitSpec_Def_ExportedE = dso_local dllexport global i32 1, align 4 |
| 216 |
template<> __declspec(dllexport) int ExportedVarTmpl<ExplicitSpec_Def_Exported> = 1; |
| 217 |
|
| 218 |
// Not exporting specialization of an exported variable template without |
| 219 |
// explicit dllexport. |
| 220 |
// MSC-DAG: @"??$ExportedVarTmpl@UExplicitSpec_NotExported@@@@3HA" = dso_local global i32 0, align 4 |
| 221 |
// GNU-DAG: @_Z15ExportedVarTmplI24ExplicitSpec_NotExportedE = dso_local global i32 0, align 4 |
| 222 |
template<> int ExportedVarTmpl<ExplicitSpec_NotExported>; |
| 223 |
|
| 224 |
|
| 225 |
// Export explicit instantiation declaration of a non-exported variable template. |
| 226 |
// MSC-DAG: @"??$VarTmpl@UExplicitDecl_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 227 |
// GNU-DAG: @_Z7VarTmplI21ExplicitDecl_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 228 |
extern template __declspec(dllexport) int VarTmpl<ExplicitDecl_Exported>; |
| 229 |
template __declspec(dllexport) int VarTmpl<ExplicitDecl_Exported>; |
| 230 |
|
| 231 |
// Export explicit instantiation definition of a non-exported variable template. |
| 232 |
// MSC-DAG: @"??$VarTmpl@UExplicitInst_Exported@@@@3HA" = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 233 |
// GNU-DAG: @_Z7VarTmplI21ExplicitInst_ExportedE = weak_odr dso_local dllexport global i32 1, comdat, align 4 |
| 234 |
template __declspec(dllexport) int VarTmpl<ExplicitInst_Exported>; |
| 235 |
|
| 236 |
// Export specialization of a non-exported variable template. |
| 237 |
// MSC-DAG: @"??$VarTmpl@UExplicitSpec_Exported@@@@3HA" = dso_local dllexport global i32 0, align 4 |
| 238 |
// GNU-DAG: @_Z7VarTmplI21ExplicitSpec_ExportedE = dso_local dllexport global i32 0, align 4 |
| 239 |
template<> __declspec(dllexport) int VarTmpl<ExplicitSpec_Exported>; |
| 240 |
|
| 241 |
// MSC-DAG: @"??$VarTmpl@UExplicitSpec_Def_Exported@@@@3HA" = dso_local dllexport global i32 1, align 4 |
| 242 |
// GNU-DAG: @_Z7VarTmplI25ExplicitSpec_Def_ExportedE = dso_local dllexport global i32 1, align 4 |
| 243 |
template<> __declspec(dllexport) int VarTmpl<ExplicitSpec_Def_Exported> = 1; |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
//===----------------------------------------------------------------------===// |
| 248 |
// Functions |
| 249 |
//===----------------------------------------------------------------------===// |
| 250 |
|
| 251 |
// Declarations are not exported. |
| 252 |
|
| 253 |
// Export function definition. |
| 254 |
// MSC-DAG: define dso_local dllexport void @"?def@@YAXXZ"() |
| 255 |
// GNU-DAG: define dso_local dllexport void @_Z3defv() |
| 256 |
__declspec(dllexport) void def() {} |
| 257 |
|
| 258 |
// extern "C" |
| 259 |
// MSC-DAG: define dso_local dllexport void @externC() |
| 260 |
// GNU-DAG: define dso_local dllexport void @externC() |
| 261 |
extern "C" __declspec(dllexport) void externC() {} |
| 262 |
|
| 263 |
// Export inline function. |
| 264 |
// MSC-DAG: define weak_odr dso_local dllexport void @"?inlineFunc@@YAXXZ"() |
| 265 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z10inlineFuncv() |
| 266 |
__declspec(dllexport) inline void inlineFunc() {} |
| 267 |
|
| 268 |
// MSC-DAG: define weak_odr dso_local dllexport void @"?inlineDecl@@YAXXZ"() |
| 269 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z10inlineDeclv() |
| 270 |
__declspec(dllexport) inline void inlineDecl(); |
| 271 |
void inlineDecl() {} |
| 272 |
|
| 273 |
// MSC-DAG: define weak_odr dso_local dllexport void @"?inlineDef@@YAXXZ"() |
| 274 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z9inlineDefv() |
| 275 |
__declspec(dllexport) void inlineDef(); |
| 276 |
inline void inlineDef() {} |
| 277 |
|
| 278 |
// Redeclarations |
| 279 |
// MSC-DAG: define dso_local dllexport void @"?redecl1@@YAXXZ"() |
| 280 |
// GNU-DAG: define dso_local dllexport void @_Z7redecl1v() |
| 281 |
__declspec(dllexport) void redecl1(); |
| 282 |
__declspec(dllexport) void redecl1() {} |
| 283 |
|
| 284 |
// MSC-DAG: define dso_local dllexport void @"?redecl2@@YAXXZ"() |
| 285 |
// GNU-DAG: define dso_local dllexport void @_Z7redecl2v() |
| 286 |
__declspec(dllexport) void redecl2(); |
| 287 |
void redecl2() {} |
| 288 |
|
| 289 |
// Friend functions |
| 290 |
// MSC-DAG: define dso_local dllexport void @"?friend1@@YAXXZ"() |
| 291 |
// GNU-DAG: define dso_local dllexport void @_Z7friend1v() |
| 292 |
// MSC-DAG: define dso_local dllexport void @"?friend2@@YAXXZ"() |
| 293 |
// GNU-DAG: define dso_local dllexport void @_Z7friend2v() |
| 294 |
struct FuncFriend { |
| 295 |
friend __declspec(dllexport) void friend1(); |
| 296 |
friend __declspec(dllexport) void friend2(); |
| 297 |
}; |
| 298 |
__declspec(dllexport) void friend1() {} |
| 299 |
void friend2() {} |
| 300 |
|
| 301 |
// MSC-DAG: define dso_local dllexport void @"?func@Befriended@@SAXXZ"() |
| 302 |
// GNU-DAG: define dso_local dllexport void @_ZN10Befriended4funcEv() |
| 303 |
struct __declspec(dllexport) Befriended { |
| 304 |
static void func(); |
| 305 |
struct Befriending { |
| 306 |
friend void Befriended::func(); |
| 307 |
}; |
| 308 |
}; |
| 309 |
void Befriended::func() {} |
| 310 |
|
| 311 |
// Implicit declarations can be redeclared with dllexport. |
| 312 |
// MSC-DAG: define dso_local dllexport nonnull ptr @"??2@{{YAPAXI|YAPEAX_K}}@Z"( |
| 313 |
// GNU-DAG: define dso_local dllexport nonnull ptr @_Znw{{[yjm]}}( |
| 314 |
void* alloc(__SIZE_TYPE__ n); |
| 315 |
__declspec(dllexport) void* operator new(__SIZE_TYPE__ n) { return alloc(n); } |
| 316 |
|
| 317 |
// MSC-DAG: define dso_local dllexport void @"?externalFunc@ns@@YAXXZ"() |
| 318 |
// GNU-DAG: define dso_local dllexport void @_ZN2ns12externalFuncEv() |
| 319 |
namespace ns { __declspec(dllexport) void externalFunc() {} } |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
//===----------------------------------------------------------------------===// |
| 324 |
// Function templates |
| 325 |
//===----------------------------------------------------------------------===// |
| 326 |
|
| 327 |
// Export function template definition. |
| 328 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplDef@UExplicitInst_Exported@@@@YAXXZ"() |
| 329 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z11funcTmplDefI21ExplicitInst_ExportedEvv() |
| 330 |
template<typename T> __declspec(dllexport) void funcTmplDef() {} |
| 331 |
INST(funcTmplDef<ExplicitInst_Exported>) |
| 332 |
|
| 333 |
// Export inline function template. |
| 334 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmpl1@UExplicitInst_Exported@@@@YAXXZ"() |
| 335 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15inlineFuncTmpl1I21ExplicitInst_ExportedEvv() |
| 336 |
template<typename T> __declspec(dllexport) inline void inlineFuncTmpl1() {} |
| 337 |
INST(inlineFuncTmpl1<ExplicitInst_Exported>) |
| 338 |
|
| 339 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmpl2@UExplicitInst_Exported@@@@YAXXZ"() |
| 340 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15inlineFuncTmpl2I21ExplicitInst_ExportedEvv() |
| 341 |
template<typename T> inline void __attribute__((dllexport)) inlineFuncTmpl2() {} |
| 342 |
INST(inlineFuncTmpl2<ExplicitInst_Exported>) |
| 343 |
|
| 344 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmplDecl@UExplicitInst_Exported@@@@YAXXZ"() |
| 345 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z18inlineFuncTmplDeclI21ExplicitInst_ExportedEvv() |
| 346 |
template<typename T> __declspec(dllexport) inline void inlineFuncTmplDecl(); |
| 347 |
template<typename T> void inlineFuncTmplDecl() {} |
| 348 |
INST(inlineFuncTmplDecl<ExplicitInst_Exported>) |
| 349 |
|
| 350 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$inlineFuncTmplDef@UExplicitInst_Exported@@@@YAXXZ"() |
| 351 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z17inlineFuncTmplDefI21ExplicitInst_ExportedEvv() |
| 352 |
template<typename T> __declspec(dllexport) void inlineFuncTmplDef(); |
| 353 |
template<typename T> inline void inlineFuncTmplDef() {} |
| 354 |
INST(inlineFuncTmplDef<ExplicitInst_Exported>) |
| 355 |
|
| 356 |
|
| 357 |
// Redeclarations |
| 358 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplRedecl1@UExplicitInst_Exported@@@@YAXXZ"() |
| 359 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplRedecl1I21ExplicitInst_ExportedEvv() |
| 360 |
template<typename T> __declspec(dllexport) void funcTmplRedecl1(); |
| 361 |
template<typename T> __declspec(dllexport) void funcTmplRedecl1() {} |
| 362 |
INST(funcTmplRedecl1<ExplicitInst_Exported>) |
| 363 |
|
| 364 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplRedecl2@UExplicitInst_Exported@@@@YAXXZ"() |
| 365 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplRedecl2I21ExplicitInst_ExportedEvv() |
| 366 |
template<typename T> __declspec(dllexport) void funcTmplRedecl2(); |
| 367 |
template<typename T> void funcTmplRedecl2() {} |
| 368 |
INST(funcTmplRedecl2<ExplicitInst_Exported>) |
| 369 |
|
| 370 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplRedecl3@UExplicitInst_Exported@@@@YAXXZ"() |
| 371 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplRedecl3I21ExplicitInst_ExportedEvv() |
| 372 |
template<typename T> __declspec(dllexport) void funcTmplRedecl3(); |
| 373 |
template<typename T> void funcTmplRedecl3() {} |
| 374 |
INST(funcTmplRedecl3<ExplicitInst_Exported>) |
| 375 |
|
| 376 |
|
| 377 |
// Function template friends |
| 378 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplFriend1@UExplicitInst_Exported@@@@YAXXZ"() |
| 379 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplFriend1I21ExplicitInst_ExportedEvv() |
| 380 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmplFriend2@UExplicitInst_Exported@@@@YAXXZ"() |
| 381 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z15funcTmplFriend2I21ExplicitInst_ExportedEvv() |
| 382 |
struct FuncTmplFriend { |
| 383 |
template<typename T> friend __declspec(dllexport) void funcTmplFriend1(); |
| 384 |
template<typename T> friend __declspec(dllexport) void funcTmplFriend2(); |
| 385 |
}; |
| 386 |
template<typename T> __declspec(dllexport) void funcTmplFriend1() {} |
| 387 |
template<typename T> void funcTmplFriend2() {} |
| 388 |
INST(funcTmplFriend1<ExplicitInst_Exported>) |
| 389 |
INST(funcTmplFriend2<ExplicitInst_Exported>) |
| 390 |
|
| 391 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$externalFuncTmpl@UExplicitInst_Exported@@@ns@@YAXXZ"() |
| 392 |
// GNU-DAG: define weak_odr dso_local dllexport void @_ZN2ns16externalFuncTmplI21ExplicitInst_ExportedEEvv() |
| 393 |
namespace ns { template<typename T> __declspec(dllexport) void externalFuncTmpl() {} } |
| 394 |
INST(ns::externalFuncTmpl<ExplicitInst_Exported>) |
| 395 |
|
| 396 |
|
| 397 |
template<typename T> void funcTmpl() {} |
| 398 |
template<typename T> __declspec(dllexport) void exportedFuncTmpl() {} |
| 399 |
|
| 400 |
// Export implicit instantiation of an exported function template. |
| 401 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UImplicitInst_Exported@@@@YAXXZ"() |
| 402 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI21ImplicitInst_ExportedEvv() |
| 403 |
USE(exportedFuncTmpl<ImplicitInst_Exported>) |
| 404 |
|
| 405 |
// Export explicit instantiation declaration of an exported function template. |
| 406 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UExplicitDecl_Exported@@@@YAXXZ"() |
| 407 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI21ExplicitDecl_ExportedEvv() |
| 408 |
extern template void exportedFuncTmpl<ExplicitDecl_Exported>(); |
| 409 |
template void exportedFuncTmpl<ExplicitDecl_Exported>(); |
| 410 |
|
| 411 |
// Export explicit instantiation definition of an exported function template. |
| 412 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UExplicitInst_Exported@@@@YAXXZ"() |
| 413 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI21ExplicitInst_ExportedEvv() |
| 414 |
template void exportedFuncTmpl<ExplicitInst_Exported>(); |
| 415 |
|
| 416 |
// Export specialization of an exported function template. |
| 417 |
// MSC-DAG: define dso_local dllexport void @"??$exportedFuncTmpl@UExplicitSpec_Def_Exported@@@@YAXXZ"() |
| 418 |
// GNU-DAG: define dso_local dllexport void @_Z16exportedFuncTmplI25ExplicitSpec_Def_ExportedEvv() |
| 419 |
template<> __declspec(dllexport) void exportedFuncTmpl<ExplicitSpec_Def_Exported>() {} |
| 420 |
|
| 421 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$exportedFuncTmpl@UExplicitSpec_InlineDef_Exported@@@@YAXXZ"() |
| 422 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z16exportedFuncTmplI31ExplicitSpec_InlineDef_ExportedEvv() |
| 423 |
template<> __declspec(dllexport) inline void exportedFuncTmpl<ExplicitSpec_InlineDef_Exported>() {} |
| 424 |
|
| 425 |
// Not exporting specialization of an exported function template without |
| 426 |
// explicit dllexport. |
| 427 |
// MSC-DAG: define dso_local void @"??$exportedFuncTmpl@UExplicitSpec_NotExported@@@@YAXXZ"() |
| 428 |
// GNU-DAG: define dso_local void @_Z16exportedFuncTmplI24ExplicitSpec_NotExportedEvv() |
| 429 |
template<> void exportedFuncTmpl<ExplicitSpec_NotExported>() {} |
| 430 |
|
| 431 |
|
| 432 |
// Export explicit instantiation declaration of a non-exported function template. |
| 433 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmpl@UExplicitDecl_Exported@@@@YAXXZ"() |
| 434 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z8funcTmplI21ExplicitDecl_ExportedEvv() |
| 435 |
extern template __declspec(dllexport) void funcTmpl<ExplicitDecl_Exported>(); |
| 436 |
template __declspec(dllexport) void funcTmpl<ExplicitDecl_Exported>(); |
| 437 |
|
| 438 |
// Export explicit instantiation definition of a non-exported function template. |
| 439 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmpl@UExplicitInst_Exported@@@@YAXXZ"() |
| 440 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z8funcTmplI21ExplicitInst_ExportedEvv() |
| 441 |
template __declspec(dllexport) void funcTmpl<ExplicitInst_Exported>(); |
| 442 |
|
| 443 |
// Export specialization of a non-exported function template. |
| 444 |
// MSC-DAG: define dso_local dllexport void @"??$funcTmpl@UExplicitSpec_Def_Exported@@@@YAXXZ"() |
| 445 |
// GNU-DAG: define dso_local dllexport void @_Z8funcTmplI25ExplicitSpec_Def_ExportedEvv() |
| 446 |
template<> __declspec(dllexport) void funcTmpl<ExplicitSpec_Def_Exported>() {} |
| 447 |
|
| 448 |
// MSC-DAG: define weak_odr dso_local dllexport void @"??$funcTmpl@UExplicitSpec_InlineDef_Exported@@@@YAXXZ"() |
| 449 |
// GNU-DAG: define weak_odr dso_local dllexport void @_Z8funcTmplI31ExplicitSpec_InlineDef_ExportedEvv() |
| 450 |
template<> __declspec(dllexport) inline void funcTmpl<ExplicitSpec_InlineDef_Exported>() {} |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
//===----------------------------------------------------------------------===// |
| 455 |
// Precedence |
| 456 |
//===----------------------------------------------------------------------===// |
| 457 |
|
| 458 |
// dllexport takes precedence over the dllimport if both are specified. |
| 459 |
// MSC-DAG: @"?PrecedenceGlobal1A@@3HA" = dso_local dllexport global i32 0, align 4 |
| 460 |
// MSC-DAG: @"?PrecedenceGlobal1B@@3HA" = dso_local dllexport global i32 0, align 4 |
| 461 |
// GNU-DAG: @PrecedenceGlobal1A = dso_local dllexport global i32 0, align 4 |
| 462 |
// GNU-DAG: @PrecedenceGlobal1B = dso_local dllexport global i32 0, align 4 |
| 463 |
__attribute__((dllimport, dllexport)) int PrecedenceGlobal1A; // dllimport ignored |
| 464 |
__declspec(dllimport) __declspec(dllexport) int PrecedenceGlobal1B; // dllimport ignored |
| 465 |
|
| 466 |
// MSC-DAG: @"?PrecedenceGlobal2A@@3HA" = dso_local dllexport global i32 0, align 4 |
| 467 |
// MSC-DAG: @"?PrecedenceGlobal2B@@3HA" = dso_local dllexport global i32 0, align 4 |
| 468 |
// GNU-DAG: @PrecedenceGlobal2A = dso_local dllexport global i32 0, align 4 |
| 469 |
// GNU-DAG: @PrecedenceGlobal2B = dso_local dllexport global i32 0, align 4 |
| 470 |
__attribute__((dllexport, dllimport)) int PrecedenceGlobal2A; // dllimport ignored |
| 471 |
__declspec(dllexport) __declspec(dllimport) int PrecedenceGlobal2B; // dllimport ignored |
| 472 |
|
| 473 |
// MSC-DAG: @"?PrecedenceGlobalRedecl1@@3HA" = dso_local dllexport global i32 0, align 4 |
| 474 |
// GNU-DAG: @PrecedenceGlobalRedecl1 = dso_local dllexport global i32 0, align 4 |
| 475 |
__declspec(dllexport) extern int PrecedenceGlobalRedecl1; |
| 476 |
__declspec(dllimport) int PrecedenceGlobalRedecl1 = 0; |
| 477 |
|
| 478 |
// MSC-DAG: @"?PrecedenceGlobalRedecl2@@3HA" = dso_local dllexport global i32 0, align 4 |
| 479 |
// GNU-DAG: @PrecedenceGlobalRedecl2 = dso_local dllexport global i32 0, align 4 |
| 480 |
__declspec(dllimport) extern int PrecedenceGlobalRedecl2; |
| 481 |
__declspec(dllexport) int PrecedenceGlobalRedecl2; |
| 482 |
|
| 483 |
// MSC-DAG: @"?PrecedenceGlobalMixed1@@3HA" = dso_local dllexport global i32 0, align 4 |
| 484 |
// GNU-DAG: @PrecedenceGlobalMixed1 = dso_local dllexport global i32 0, align 4 |
| 485 |
__attribute__((dllexport)) extern int PrecedenceGlobalMixed1; |
| 486 |
__declspec(dllimport) int PrecedenceGlobalMixed1 = 0; |
| 487 |
|
| 488 |
// MSC-DAG: @"?PrecedenceGlobalMixed2@@3HA" = dso_local dllexport global i32 0, align 4 |
| 489 |
// GNU-DAG: @PrecedenceGlobalMixed2 = dso_local dllexport global i32 0, align 4 |
| 490 |
__attribute__((dllimport)) extern int PrecedenceGlobalMixed2; |
| 491 |
__declspec(dllexport) int PrecedenceGlobalMixed2; |
| 492 |
|
| 493 |
// MSC-DAG: define dso_local dllexport void @"?precedence1A@@YAXXZ" |
| 494 |
// MSC-DAG: define dso_local dllexport void @"?precedence1B@@YAXXZ" |
| 495 |
// GNU-DAG: define dso_local dllexport void @_Z12precedence1Av() |
| 496 |
// GNU-DAG: define dso_local dllexport void @_Z12precedence1Bv() |
| 497 |
void __attribute__((dllimport, dllexport)) precedence1A() {} |
| 498 |
void __declspec(dllimport) __declspec(dllexport) precedence1B() {} |
| 499 |
|
| 500 |
// MSC-DAG: define dso_local dllexport void @"?precedence2A@@YAXXZ" |
| 501 |
// MSC-DAG: define dso_local dllexport void @"?precedence2B@@YAXXZ" |
| 502 |
// GNU-DAG: define dso_local dllexport void @_Z12precedence2Av() |
| 503 |
// GNU-DAG: define dso_local dllexport void @_Z12precedence2Bv() |
| 504 |
void __attribute__((dllexport, dllimport)) precedence2A() {} |
| 505 |
void __declspec(dllexport) __declspec(dllimport) precedence2B() {} |
| 506 |
|
| 507 |
// MSC-DAG: define dso_local dllexport void @"?precedenceRedecl1@@YAXXZ" |
| 508 |
// GNU-DAG: define dso_local dllexport void @_Z17precedenceRedecl1v() |
| 509 |
void __declspec(dllimport) precedenceRedecl1(); |
| 510 |
void __declspec(dllexport) precedenceRedecl1() {} |
| 511 |
|
| 512 |
// MSC-DAG: define dso_local dllexport void @"?precedenceRedecl2@@YAXXZ" |
| 513 |
// GNU-DAG: define dso_local dllexport void @_Z17precedenceRedecl2v() |
| 514 |
void __declspec(dllexport) precedenceRedecl2(); |
| 515 |
void __declspec(dllimport) precedenceRedecl2() {} |
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
//===----------------------------------------------------------------------===// |
| 520 |
// Classes |
| 521 |
//===----------------------------------------------------------------------===// |
| 522 |
|
| 523 |
struct S { |
| 524 |
void __declspec(dllexport) a() {} |
| 525 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?a@S@@QAEXXZ" |
| 526 |
|
| 527 |
struct T { |
| 528 |
void __declspec(dllexport) a() {} |
| 529 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?a@T@S@@QAEXXZ" |
| 530 |
}; |
| 531 |
}; |
| 532 |
|
| 533 |
template <typename T> |
| 534 |
struct SomeTemplate { |
| 535 |
SomeTemplate(T o = T()) : o(o) {} |
| 536 |
T o; |
| 537 |
}; |
| 538 |
// MSVC2015-DAG: define weak_odr dso_local dllexport {{.+}} @"??4?$SomeTemplate@H@@Q{{.+}}@$$Q{{.+}}@@Z" |
| 539 |
// MSVC2013-DAG: define weak_odr dso_local dllexport {{.+}} @"??4?$SomeTemplate@H@@Q{{.+}}0@A{{.+}}0@@Z" |
| 540 |
struct __declspec(dllexport) InheritFromTemplate : SomeTemplate<int> {}; |
| 541 |
|
| 542 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??_F?$SomeTemplate@H@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat |
| 543 |
|
| 544 |
namespace PR23801 { |
| 545 |
template <typename> |
| 546 |
struct S { |
| 547 |
~S() {} |
| 548 |
}; |
| 549 |
struct A { |
| 550 |
A(int); |
| 551 |
S<int> s; |
| 552 |
}; |
| 553 |
struct __declspec(dllexport) B { |
| 554 |
B(A = 0) {} |
| 555 |
}; |
| 556 |
|
| 557 |
} |
| 558 |
// |
| 559 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FB@PR23801@@QAEXXZ"({{.*}}) {{#[0-9]+}} comdat |
| 560 |
|
| 561 |
struct __declspec(dllexport) T { |
| 562 |
// Copy assignment operator: |
| 563 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"??4T@@QAEAAU0@ABU0@@Z" |
| 564 |
|
| 565 |
// Explicitly defaulted copy constructur: |
| 566 |
T(const T&) = default; |
| 567 |
// M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0T@@QAE@ABU0@@Z" |
| 568 |
|
| 569 |
void a() {} |
| 570 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?a@T@@QAEXXZ" |
| 571 |
|
| 572 |
static int b; |
| 573 |
// M32-DAG: @"?b@T@@2HA" = external dso_local global i32 |
| 574 |
|
| 575 |
static int c; |
| 576 |
// M32-DAG: @"?c@T@@2HA" = dso_local dllexport global i32 0, align 4 |
| 577 |
}; |
| 578 |
|
| 579 |
USEVAR(T::b) |
| 580 |
int T::c; |
| 581 |
|
| 582 |
// Export template class with static member variable |
| 583 |
// MSC-DAG: @"?StaticClassVarExpTmplClass@?$TmplClass@H@@2HA" = weak_odr dso_local dllexport global i32 0, comdat, align 4 |
| 584 |
// GNU-DAG: @_ZN9TmplClassIiE26StaticClassVarExpTmplClassE = weak_odr dso_local dllexport global i32 0, comdat, align 4 |
| 585 |
template<typename T> |
| 586 |
struct __declspec(dllexport) TmplClass |
| 587 |
{ |
| 588 |
static T StaticClassVarExpTmplClass; |
| 589 |
}; |
| 590 |
|
| 591 |
template<typename T> |
| 592 |
T TmplClass<T>::StaticClassVarExpTmplClass; |
| 593 |
|
| 594 |
// Export a definition of a template function. |
| 595 |
// MSC-DAG: define weak_odr dso_local dllexport i32 @"??$TypeFunTmpl@H@@YAHH@Z" |
| 596 |
// GNU-DAG: define weak_odr dso_local dllexport i32 @_Z11TypeFunTmplIiET_S0_ |
| 597 |
template<typename T> |
| 598 |
T __declspec(dllexport) TypeFunTmpl(T t) { return t + t; } |
| 599 |
|
| 600 |
// Instantiate the exported template class and the exported template function. |
| 601 |
int useExportedTmplStaticAndFun() |
| 602 |
{ |
| 603 |
return TmplClass<int>::StaticClassVarExpTmplClass + TypeFunTmpl<int>(10); |
| 604 |
} |
| 605 |
|
| 606 |
template <typename T> struct __declspec(dllexport) U { void foo() {} }; |
| 607 |
struct __declspec(dllexport) V : public U<int> { }; |
| 608 |
// U<int>'s assignment operator is emitted. |
| 609 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"??4?$U@H@@QAEAAU0@ABU0@@Z" |
| 610 |
|
| 611 |
struct __declspec(dllexport) W { virtual void foo(); }; |
| 612 |
void W::foo() {} |
| 613 |
// Default ctor: |
| 614 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0W@@QAE@XZ" |
| 615 |
// Copy ctor: |
| 616 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0W@@QAE@ABU0@@Z" |
| 617 |
// vftable: |
| 618 |
// M32-DAG: [[W_VTABLE:@.*]] = private unnamed_addr constant { [2 x ptr] } { [2 x ptr] [ptr @"??_R4W@@6B@", ptr @"?foo@W@@UAEXXZ"] }, comdat($"??_7W@@6B@") |
| 619 |
// M32-DAG: @"??_7W@@6B@" = dllexport unnamed_addr alias ptr, getelementptr inbounds ({ [2 x ptr] }, ptr [[W_VTABLE]], i32 0, i32 0, i32 1) |
| 620 |
// G32-DAG: @_ZTV1W = dso_local dllexport unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1W, ptr @_ZN1W3fooEv] } |
| 621 |
// C32-DAG: @_ZTV1W = dso_local dllexport unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1W, ptr @_ZN1W3fooEv] } |
| 622 |
|
| 623 |
struct __declspec(dllexport) X : public virtual W {}; |
| 624 |
// vbtable: |
| 625 |
// M32-DAG: @"??_8X@@7B@" = weak_odr dllexport unnamed_addr constant [2 x i32] [i32 0, i32 4] |
| 626 |
|
| 627 |
struct __declspec(dllexport) Y { |
| 628 |
// Move assignment operator: |
| 629 |
// MSVC2015-DAG: define weak_odr dso_local dllexport {{.+}} @"??4Y@@Q{{.+}}@$$Q{{.+}}@@Z" |
| 630 |
// MSVC2013-DAG: define weak_odr dso_local dllexport {{.+}} @"??4Y@@Q{{.+}}0@A{{.+}}0@@Z" |
| 631 |
|
| 632 |
int x; |
| 633 |
}; |
| 634 |
|
| 635 |
struct __declspec(dllexport) Z { virtual ~Z() {} }; |
| 636 |
// The deleting dtor does not get exported, but we emit body of vector deleting |
| 637 |
// destructor: |
| 638 |
// M32-DAG: define weak dso_local x86_thiscallcc ptr @"??_EZ@@UAEPAXI@Z" |
| 639 |
|
| 640 |
|
| 641 |
// The user-defined dtor does get exported: |
| 642 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??1Z@@UAE@XZ" |
| 643 |
|
| 644 |
namespace UseDtorAlias { |
| 645 |
struct __declspec(dllexport) A { ~A(); }; |
| 646 |
struct __declspec(dllexport) B : A { ~B(); }; |
| 647 |
A::~A() { } |
| 648 |
B::~B() { } |
| 649 |
// Emit a alias definition of B's constructor. |
| 650 |
// M32-DAG: @"??1B@UseDtorAlias@@QAE@XZ" = dso_local dllexport unnamed_addr alias {{.*}} @"??1A@UseDtorAlias@@QAE@XZ" |
| 651 |
} |
| 652 |
|
| 653 |
struct __declspec(dllexport) DefaultedCtorsDtors { |
| 654 |
DefaultedCtorsDtors() = default; |
| 655 |
// M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0DefaultedCtorsDtors@@QAE@XZ" |
| 656 |
~DefaultedCtorsDtors() = default; |
| 657 |
// M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??1DefaultedCtorsDtors@@QAE@XZ" |
| 658 |
}; |
| 659 |
|
| 660 |
// Export defaulted member function definitions declared inside class. |
| 661 |
struct __declspec(dllexport) ExportDefaultedInclassDefs { |
| 662 |
ExportDefaultedInclassDefs() = default; |
| 663 |
// M32VS2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ExportDefaultedInclassDefs@@QAE@XZ"(ptr returned %this) |
| 664 |
// M64VS2013-DAG: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@XZ"(ptr returned %this) |
| 665 |
// M32VS2015-NOT: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ExportDefaultedInclassDefs@@QAE@XZ"(ptr returned %this) |
| 666 |
// M64VS2015-NOT: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@XZ"(ptr returned %this) |
| 667 |
|
| 668 |
~ExportDefaultedInclassDefs() = default; |
| 669 |
// M32VS2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??1ExportDefaultedInclassDefs@@QAE@XZ"(ptr %this) |
| 670 |
// M64VS2013-DAG: define weak_odr dso_local dllexport void @"??1ExportDefaultedInclassDefs@@QEAA@XZ"(ptr %this) |
| 671 |
// M32VS2015-NOT: define weak_odr dso_local dllexport x86_thiscallcc void @"??1ExportDefaultedInclassDefs@@QAE@XZ"(ptr %this) |
| 672 |
// M64VS2015-NOT: define weak_odr dso_local dllexport void @"??1ExportDefaultedInclassDefs@@QEAA@XZ"(ptr %this) |
| 673 |
|
| 674 |
ExportDefaultedInclassDefs(const ExportDefaultedInclassDefs&) = default; |
| 675 |
// 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]+}})) |
| 676 |
// M64VS2013-DAG: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@AEBU0@@Z"(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}})) |
| 677 |
// 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]+}})) |
| 678 |
// M64VS2015-NOT: define weak_odr dso_local dllexport ptr @"??0ExportDefaultedInclassDefs@@QEAA@AEBU0@@Z"(ptr {{[^,]*}} returned {{[^,]*}} %this, ptr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}})) |
| 679 |
|
| 680 |
ExportDefaultedInclassDefs& operator=(const ExportDefaultedInclassDefs&) = default; |
| 681 |
// 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) |
| 682 |
// 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) |
| 683 |
}; |
| 684 |
|
| 685 |
namespace ReferencedInlineMethodInNestedClass { |
| 686 |
struct __declspec(dllexport) S { |
| 687 |
void foo() { |
| 688 |
t->bar(); |
| 689 |
} |
| 690 |
struct T { |
| 691 |
void bar() {} |
| 692 |
}; |
| 693 |
T *t; |
| 694 |
}; |
| 695 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?foo@S@ReferencedInlineMethodInNestedClass@@QAEXXZ" |
| 696 |
// M32-DAG: define linkonce_odr dso_local x86_thiscallcc void @"?bar@T@S@ReferencedInlineMethodInNestedClass@@QAEXXZ" |
| 697 |
} |
| 698 |
|
| 699 |
// MS ignores DLL attributes on partial specializations. |
| 700 |
template <typename T> struct PartiallySpecializedClassTemplate {}; |
| 701 |
template <typename T> struct __declspec(dllexport) PartiallySpecializedClassTemplate<T*> { void f(); }; |
| 702 |
template <typename T> void PartiallySpecializedClassTemplate<T*>::f() {} |
| 703 |
USEMEMFUNC(PartiallySpecializedClassTemplate<void*>, f); |
| 704 |
// M32-DAG: define linkonce_odr dso_local x86_thiscallcc void @"?f@?$PartiallySpecializedClassTemplate@PAX@@QAEXXZ" |
| 705 |
// G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv |
| 706 |
// C32-DAG: define weak_odr dso_local dllexport void @_ZN33PartiallySpecializedClassTemplateIPvE1fEv |
| 707 |
|
| 708 |
// Attributes on explicit specializations are honored. |
| 709 |
template <typename T> struct ExplicitlySpecializedClassTemplate {}; |
| 710 |
template <> struct __declspec(dllexport) ExplicitlySpecializedClassTemplate<void*> { void f(); }; |
| 711 |
void ExplicitlySpecializedClassTemplate<void*>::f() {} |
| 712 |
USEMEMFUNC(ExplicitlySpecializedClassTemplate<void*>, f); |
| 713 |
// M32-DAG: define dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitlySpecializedClassTemplate@PAX@@QAEXXZ" |
| 714 |
// G32-DAG: define dso_local dllexport x86_thiscallcc void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv |
| 715 |
// C32-DAG: define dso_local dllexport void @_ZN34ExplicitlySpecializedClassTemplateIPvE1fEv |
| 716 |
|
| 717 |
// MS inherits DLL attributes to partial specializations. |
| 718 |
template <typename T> struct __declspec(dllexport) PartiallySpecializedExportedClassTemplate {}; |
| 719 |
template <typename T> struct PartiallySpecializedExportedClassTemplate<T*> { void f() {} }; |
| 720 |
USEMEMFUNC(PartiallySpecializedExportedClassTemplate<void*>, f); |
| 721 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$PartiallySpecializedExportedClassTemplate@PAX@@QAEXXZ" |
| 722 |
// G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN41PartiallySpecializedExportedClassTemplateIPvE1fEv |
| 723 |
// C32-DAG: define linkonce_odr dso_local void @_ZN41PartiallySpecializedExportedClassTemplateIPvE1fEv |
| 724 |
|
| 725 |
// MS ignores DLL attributes on partial specializations; inheritance still works though. |
| 726 |
template <typename T> struct __declspec(dllexport) PartiallySpecializedExportedClassTemplate2 {}; |
| 727 |
template <typename T> struct __declspec(dllimport) PartiallySpecializedExportedClassTemplate2<T*> { void f(); }; |
| 728 |
template <typename T> void PartiallySpecializedExportedClassTemplate2<T*>::f() {} |
| 729 |
USEMEMFUNC(PartiallySpecializedExportedClassTemplate2<void*>, f); |
| 730 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$PartiallySpecializedExportedClassTemplate2@PAX@@QAEXXZ" |
| 731 |
// G32-DAG: declare dllimport x86_thiscallcc void @_ZN42PartiallySpecializedExportedClassTemplate2IPvE1fEv |
| 732 |
// C32-DAG: declare dllimport void @_ZN42PartiallySpecializedExportedClassTemplate2IPvE1fEv |
| 733 |
|
| 734 |
// Attributes on the instantiation take precedence over attributes on the template. |
| 735 |
template <typename T> struct __declspec(dllimport) ExplicitlyInstantiatedWithDifferentAttr { void f() {} }; |
| 736 |
template struct __declspec(dllexport) ExplicitlyInstantiatedWithDifferentAttr<int>; |
| 737 |
USEMEMFUNC(ExplicitlyInstantiatedWithDifferentAttr<int>, f); |
| 738 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitlyInstantiatedWithDifferentAttr@H@@QAEXXZ" |
| 739 |
|
| 740 |
// Don't create weak dllexport aliases. (PR21373) |
| 741 |
struct NonExportedBaseClass { |
| 742 |
virtual ~NonExportedBaseClass(); |
| 743 |
}; |
| 744 |
NonExportedBaseClass::~NonExportedBaseClass() {} |
| 745 |
|
| 746 |
struct __declspec(dllexport) ExportedDerivedClass : NonExportedBaseClass {}; |
| 747 |
// M32-DAG: weak_odr dso_local dllexport x86_thiscallcc void @"??1ExportedDerivedClass@@UAE@XZ" |
| 748 |
|
| 749 |
// Do not assert about generating code for constexpr functions twice during explicit instantiation (PR21718). |
| 750 |
template <typename T> struct ExplicitInstConstexprMembers { |
| 751 |
// Copy assignment operator |
| 752 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align 1 dereferenceable(1) ptr @"??4?$ExplicitInstConstexprMembers@X@@QAEAAU0@ABU0@@Z" |
| 753 |
|
| 754 |
constexpr ExplicitInstConstexprMembers() {} |
| 755 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$ExplicitInstConstexprMembers@X@@QAE@XZ" |
| 756 |
|
| 757 |
ExplicitInstConstexprMembers(const ExplicitInstConstexprMembers&) = default; |
| 758 |
// M32MSVC2013-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$ExplicitInstConstexprMembers@X@@QAE@ABU0@@Z" |
| 759 |
|
| 760 |
constexpr int f() const { return 42; } |
| 761 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc i32 @"?f@?$ExplicitInstConstexprMembers@X@@QBEHXZ" |
| 762 |
}; |
| 763 |
template struct __declspec(dllexport) ExplicitInstConstexprMembers<void>; |
| 764 |
|
| 765 |
template <typename T> struct ExplicitInstantiationDeclTemplate { void f() {} }; |
| 766 |
extern template struct __declspec(dllexport) ExplicitInstantiationDeclTemplate<int>; |
| 767 |
USEMEMFUNC(ExplicitInstantiationDeclTemplate<int>, f); |
| 768 |
// M32-DAG: {{declare|define available_externally}} dso_local x86_thiscallcc void @"?f@?$ExplicitInstantiationDeclTemplate@H@@QAEXXZ" |
| 769 |
|
| 770 |
template <typename T> struct __declspec(dllexport) ExplicitInstantiationDeclExportedTemplate { void f() {} }; |
| 771 |
extern template struct ExplicitInstantiationDeclExportedTemplate<int>; |
| 772 |
USEMEMFUNC(ExplicitInstantiationDeclExportedTemplate<int>, f); |
| 773 |
// M32-DAG: {{declare|define available_externally}} dso_local x86_thiscallcc void @"?f@?$ExplicitInstantiationDeclExportedTemplate@H@@QAEXXZ" |
| 774 |
|
| 775 |
template <typename T> struct ExplicitInstantiationDeclExportedDefTemplate { void f() {} ExplicitInstantiationDeclExportedDefTemplate() {} }; |
| 776 |
extern template struct ExplicitInstantiationDeclExportedDefTemplate<int>; |
| 777 |
template struct __declspec(dllexport) ExplicitInstantiationDeclExportedDefTemplate<int>; |
| 778 |
USEMEMFUNC(ExplicitInstantiationDeclExportedDefTemplate<int>, f); |
| 779 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAEXXZ" |
| 780 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$ExplicitInstantiationDeclExportedDefTemplate@H@@QAE@XZ" |
| 781 |
// G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv |
| 782 |
// C32-DAG: define weak_odr dso_local void @_ZN44ExplicitInstantiationDeclExportedDefTemplateIiE1fEv |
| 783 |
|
| 784 |
template <typename T> struct ImplicitInstantiationExportedExplicitInstantiationDefTemplate { virtual void f() {} }; |
| 785 |
ImplicitInstantiationExportedExplicitInstantiationDefTemplate<int> ImplicitInstantiationExportedExplicitInstantiationDefTemplateInstance; |
| 786 |
template struct __declspec(dllexport) ImplicitInstantiationExportedExplicitInstantiationDefTemplate<int>; |
| 787 |
USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefTemplate<int>, f); |
| 788 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ImplicitInstantiationExportedExplicitInstantiationDefTemplate@H@@UAEXXZ" |
| 789 |
// G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN61ImplicitInstantiationExportedExplicitInstantiationDefTemplateIiE1fEv |
| 790 |
// C32-DAG: define weak_odr dso_local void @_ZN61ImplicitInstantiationExportedExplicitInstantiationDefTemplateIiE1fEv |
| 791 |
|
| 792 |
template <typename T> struct __declspec(dllexport) ImplicitInstantiationExplicitInstantiationDefExportedTemplate { virtual void f() {} }; |
| 793 |
ImplicitInstantiationExplicitInstantiationDefExportedTemplate<int> ImplicitInstantiationExplicitInstantiationDefExportedTemplateInstance; |
| 794 |
template struct ImplicitInstantiationExplicitInstantiationDefExportedTemplate<int>; |
| 795 |
USEMEMFUNC(ImplicitInstantiationExplicitInstantiationDefExportedTemplate<int>, f); |
| 796 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ImplicitInstantiationExplicitInstantiationDefExportedTemplate@H@@UAEXXZ" |
| 797 |
// G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN61ImplicitInstantiationExplicitInstantiationDefExportedTemplateIiE1fEv |
| 798 |
// C32-DAG: define weak_odr dso_local void @_ZN61ImplicitInstantiationExplicitInstantiationDefExportedTemplateIiE1fEv |
| 799 |
|
| 800 |
template <typename T> struct __declspec(dllexport) ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate { virtual void f() {} }; |
| 801 |
ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate<int> ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateInstance; |
| 802 |
template struct __declspec(dllexport) ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate<int>; |
| 803 |
USEMEMFUNC(ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate<int>, f); |
| 804 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplate@H@@UAEXXZ" |
| 805 |
// G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN69ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateIiE1fEv |
| 806 |
// C32-DAG: define weak_odr dso_local void @_ZN69ImplicitInstantiationExportedExplicitInstantiationDefExportedTemplateIiE1fEv |
| 807 |
|
| 808 |
namespace { struct InternalLinkageType {}; } |
| 809 |
struct __declspec(dllexport) PR23308 { |
| 810 |
void f(InternalLinkageType*); |
| 811 |
}; |
| 812 |
void PR23308::f(InternalLinkageType*) {} |
| 813 |
long use(PR23308* p) { p->f(nullptr); } |
| 814 |
// M32-DAG: define internal x86_thiscallcc void @"?f@PR23308@@QAEXPAUInternalLinkageType@?A0x{{[^@]*}}@@@Z" |
| 815 |
|
| 816 |
template <typename T> struct PR23770BaseTemplate { void f() {} }; |
| 817 |
template <typename T> struct PR23770DerivedTemplate : PR23770BaseTemplate<int> {}; |
| 818 |
extern template struct PR23770DerivedTemplate<int>; |
| 819 |
template struct __declspec(dllexport) PR23770DerivedTemplate<int>; |
| 820 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$PR23770BaseTemplate@H@@QAEXXZ" |
| 821 |
|
| 822 |
namespace InClassInits { |
| 823 |
|
| 824 |
struct __declspec(dllexport) S { |
| 825 |
int x = 42; |
| 826 |
}; |
| 827 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0S@InClassInits@@QAE@XZ" |
| 828 |
|
| 829 |
// dllexport an already instantiated class template. |
| 830 |
template <typename T> struct Base { |
| 831 |
int x = 42; |
| 832 |
}; |
| 833 |
Base<int> base; |
| 834 |
struct __declspec(dllexport) T : Base<int> { }; |
| 835 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$Base@H@InClassInits@@QAE@XZ" |
| 836 |
|
| 837 |
struct A { A(int); }; |
| 838 |
struct __declspec(dllexport) U { |
| 839 |
// Class with both default constructor closure and in-class initializer. |
| 840 |
U(A = 0) {} |
| 841 |
int x = 0; |
| 842 |
}; |
| 843 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0U@InClassInits@@QAE@UA@1@@Z" |
| 844 |
|
| 845 |
struct Evil { |
| 846 |
template <typename T> struct Base { |
| 847 |
int x = 0; |
| 848 |
}; |
| 849 |
struct S : Base<int> {}; |
| 850 |
// The already instantiated Base<int> becomes dllexported below, but the |
| 851 |
// in-class initializer for Base<>::x still hasn't been parsed, so emitting |
| 852 |
// the default ctor must still be delayed. |
| 853 |
struct __declspec(dllexport) T : Base<int> {}; |
| 854 |
}; |
| 855 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$Base@H@Evil@InClassInits@@QAE@XZ" |
| 856 |
|
| 857 |
template <typename T> struct Foo {}; |
| 858 |
template <typename T> struct Bar { |
| 859 |
Bar<T> &operator=(Foo<T>) {} |
| 860 |
}; |
| 861 |
struct __declspec(dllexport) Baz { |
| 862 |
Bar<int> n; |
| 863 |
}; |
| 864 |
// After parsing Baz, in ActOnFinishCXXNonNestedClass we would synthesize |
| 865 |
// Baz's operator=, causing instantiation of Foo<int> after which |
| 866 |
// ActOnFinishCXXNonNestedClass is called, and we would bite our own tail. |
| 867 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc nonnull align 1 dereferenceable(1) ptr @"??4Baz@InClassInits@@QAEAAU01@ABU01@@Z" |
| 868 |
|
| 869 |
// Trying to define the explicitly defaulted ctor must be delayed until the |
| 870 |
// in-class initializer for x has been processed. |
| 871 |
struct PR40006 { |
| 872 |
__declspec(dllexport) PR40006() = default; |
| 873 |
int x = 42; |
| 874 |
}; |
| 875 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0PR40006@InClassInits@@QAE@XZ" |
| 876 |
|
| 877 |
namespace pr40006 { |
| 878 |
// Delay emitting the method also past the instantiation of Tmpl<Inner>, i.e. |
| 879 |
// until the top-level class Outer is completely finished. |
| 880 |
template<typename> struct Tmpl {}; |
| 881 |
struct Outer { |
| 882 |
struct Inner { |
| 883 |
__declspec(dllexport) Inner() = default; |
| 884 |
unsigned int x = 0; |
| 885 |
}; |
| 886 |
Tmpl<Inner> y; |
| 887 |
}; |
| 888 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0Inner@Outer@pr40006@InClassInits@@QAE@XZ" |
| 889 |
} |
| 890 |
|
| 891 |
// PR42857: Clang would try to emit the non-trivial explicitly defaulted |
| 892 |
// dllexport ctor twice when doing an explicit instantiation definition. |
| 893 |
struct Qux { Qux(); }; |
| 894 |
template <typename T> struct PR42857 { __declspec(dllexport) PR42857() = default; Qux q; }; |
| 895 |
template struct PR42857<int>; |
| 896 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$PR42857@H@InClassInits@@QAE@XZ" |
| 897 |
|
| 898 |
} |
| 899 |
|
| 900 |
// We had an issue where instantiating A would force emission of B's delayed |
| 901 |
// exported methods. |
| 902 |
namespace pr26490 { |
| 903 |
template <typename T> struct A { }; |
| 904 |
struct __declspec(dllexport) B { |
| 905 |
B(int = 0) {} |
| 906 |
A<int> m_fn1() {} |
| 907 |
}; |
| 908 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"??_FB@pr26490@@QAEXXZ" |
| 909 |
} |
| 910 |
|
| 911 |
// dllexport trumps dllimport on an explicit instantiation. |
| 912 |
template <typename T> struct ExplicitInstantiationTwoAttributes { void f() {} }; |
| 913 |
template struct __declspec(dllexport) __declspec(dllimport) ExplicitInstantiationTwoAttributes<int>; |
| 914 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ" |
| 915 |
|
| 916 |
namespace pr34849 { |
| 917 |
// Specializations of exported class template member functions get exported. |
| 918 |
template <typename> struct __declspec(dllexport) ExportedClassTemplate { void foo(); }; |
| 919 |
template<> void ExportedClassTemplate<int>::foo() {} |
| 920 |
template struct ExportedClassTemplate<int>; |
| 921 |
// M32-DAG: define dso_local dllexport x86_thiscallcc void @"?foo@?$ExportedClassTemplate@H@pr34849@@QAEXXZ" |
| 922 |
|
| 923 |
// Specializations of exported class member template functions do not get exported. |
| 924 |
struct __declspec(dllexport) ExportedClass { template <typename> void bar() ; }; |
| 925 |
template<> void ExportedClass::bar<int>() {} |
| 926 |
// M32-DAG: define dso_local x86_thiscallcc void @"??$bar@H@ExportedClass@pr34849@@QAEXXZ" |
| 927 |
template <typename> struct __declspec(dllexport) ExportedClassTemplate2 { template <typename> void baz(); }; |
| 928 |
template<> template<> void ExportedClassTemplate2<int>::baz<int>() {} |
| 929 |
// M32-DAG: define dso_local x86_thiscallcc void @"??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ" |
| 930 |
} |
| 931 |
|
| 932 |
namespace pr47683 { |
| 933 |
struct X { X() {} }; |
| 934 |
|
| 935 |
template <typename> struct S { |
| 936 |
S() = default; |
| 937 |
X x; |
| 938 |
}; |
| 939 |
template struct __declspec(dllexport) S<int>; |
| 940 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$S@H@pr47683@@QAE@XZ" |
| 941 |
|
| 942 |
template <typename> struct T { |
| 943 |
T() = default; |
| 944 |
X x; |
| 945 |
}; |
| 946 |
extern template struct T<int>; |
| 947 |
template struct __declspec(dllexport) T<int>; |
| 948 |
// Don't assert about multiple codegen for explicitly defaulted method in explicit instantiation def. |
| 949 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$T@H@pr47683@@QAE@XZ" |
| 950 |
|
| 951 |
template <typename> struct U { |
| 952 |
U(); |
| 953 |
X x; |
| 954 |
}; |
| 955 |
template <typename T> U<T>::U() = default; |
| 956 |
extern template struct U<int>; |
| 957 |
template struct __declspec(dllexport) U<int>; |
| 958 |
// Same as T, but with out-of-line ctor. |
| 959 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0?$U@H@pr47683@@QAE@XZ" |
| 960 |
} |
| 961 |
|
| 962 |
//===----------------------------------------------------------------------===// |
| 963 |
// Classes with template base classes |
| 964 |
//===----------------------------------------------------------------------===// |
| 965 |
|
| 966 |
template <typename T> struct ClassTemplate { void func(); }; |
| 967 |
template <typename T> void ClassTemplate<T>::func() {} |
| 968 |
template <typename T> struct __declspec(dllexport) ExportedClassTemplate { void func(); }; |
| 969 |
template <typename T> void ExportedClassTemplate<T>::func() {} |
| 970 |
template <typename T> struct __declspec(dllimport) ImportedClassTemplate { void func(); }; |
| 971 |
template <typename T> void ImportedClassTemplate<T>::func() {} |
| 972 |
|
| 973 |
template <typename T> struct ExplicitlySpecializedTemplate { void func() {} }; |
| 974 |
template <> struct ExplicitlySpecializedTemplate<int> { void func(); }; |
| 975 |
void ExplicitlySpecializedTemplate<int>::func() {} |
| 976 |
template <typename T> struct ExplicitlyExportSpecializedTemplate { void func() {} }; |
| 977 |
template <> struct __declspec(dllexport) ExplicitlyExportSpecializedTemplate<int> { void func(); }; |
| 978 |
void ExplicitlyExportSpecializedTemplate<int>::func() {} |
| 979 |
template <typename T> struct ExplicitlyImportSpecializedTemplate { void func(); }; |
| 980 |
template <> struct __declspec(dllimport) ExplicitlyImportSpecializedTemplate<int> { void func(); }; |
| 981 |
|
| 982 |
template <typename T> struct ExplicitlyInstantiatedTemplate { void func(); }; |
| 983 |
template <typename T> void ExplicitlyInstantiatedTemplate<T>::func() {} |
| 984 |
template struct ExplicitlyInstantiatedTemplate<int>; |
| 985 |
template <typename T> struct ExplicitlyExportInstantiatedTemplate { void func(); }; |
| 986 |
template <typename T> void ExplicitlyExportInstantiatedTemplate<T>::func() {} |
| 987 |
template struct __declspec(dllexport) ExplicitlyExportInstantiatedTemplate<int>; |
| 988 |
template <typename T> struct ExplicitlyImportInstantiatedTemplate { void func(); }; |
| 989 |
template struct __declspec(dllimport) ExplicitlyImportInstantiatedTemplate<int>; |
| 990 |
|
| 991 |
|
| 992 |
// MS: ClassTemplate<int> gets exported. |
| 993 |
struct __declspec(dllexport) DerivedFromTemplate : public ClassTemplate<int> {}; |
| 994 |
USEMEMFUNC(DerivedFromTemplate, func) |
| 995 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ClassTemplate@H@@QAEXXZ" |
| 996 |
// G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN13ClassTemplateIiE4funcEv |
| 997 |
// C32-DAG: define linkonce_odr dso_local void @_ZN13ClassTemplateIiE4funcEv |
| 998 |
// PS-DAG: define weak_odr dllexport void @_ZN13ClassTemplateIiE4funcEv |
| 999 |
|
| 1000 |
// ExportedTemplate is explicitly exported. |
| 1001 |
struct __declspec(dllexport) DerivedFromExportedTemplate : public ExportedClassTemplate<int> {}; |
| 1002 |
USEMEMFUNC(DerivedFromExportedTemplate, func) |
| 1003 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ExportedClassTemplate@H@@QAEXXZ" |
| 1004 |
// G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @_ZN21ExportedClassTemplateIiE4funcEv |
| 1005 |
// C32-DAG: define weak_odr dso_local dllexport void @_ZN21ExportedClassTemplateIiE4funcEv |
| 1006 |
// PS-DAG: define weak_odr dllexport void @_ZN21ExportedClassTemplateIiE4funcEv |
| 1007 |
|
| 1008 |
// ImportedClassTemplate is explicitly imported. |
| 1009 |
struct __declspec(dllexport) DerivedFromImportedTemplate : public ImportedClassTemplate<int> {}; |
| 1010 |
USEMEMFUNC(DerivedFromImportedTemplate, func) |
| 1011 |
// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"?func@?$ImportedClassTemplate@H@@QAEXXZ" |
| 1012 |
// G32-DAG: declare dllimport x86_thiscallcc void @_ZN21ImportedClassTemplateIiE4funcEv |
| 1013 |
// C32-DAG: declare dllimport void @_ZN21ImportedClassTemplateIiE4funcEv |
| 1014 |
// PS-DAG: declare dllimport void @_ZN21ImportedClassTemplateIiE4funcEv |
| 1015 |
|
| 1016 |
// Base class already implicitly instantiated without dll attribute. |
| 1017 |
struct DerivedFromTemplateD : public ClassTemplate<double> {}; |
| 1018 |
struct __declspec(dllexport) DerivedFromTemplateD2 : public ClassTemplate<double> {}; |
| 1019 |
USEMEMFUNC(DerivedFromTemplateD2, func) |
| 1020 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ClassTemplate@N@@QAEXXZ" |
| 1021 |
// G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN13ClassTemplateIdE4funcEv |
| 1022 |
// C32-DAG: define linkonce_odr dso_local void @_ZN13ClassTemplateIdE4funcEv |
| 1023 |
// PS-DAG: define weak_odr dllexport void @_ZN13ClassTemplateIdE4funcEv |
| 1024 |
|
| 1025 |
// MS: Base class already instantiated with different dll attribute. |
| 1026 |
struct __declspec(dllimport) DerivedFromTemplateB : public ClassTemplate<bool> {}; |
| 1027 |
struct __declspec(dllexport) DerivedFromTemplateB2 : public ClassTemplate<bool> {}; |
| 1028 |
USEMEMFUNC(DerivedFromTemplateB2, func) |
| 1029 |
// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"?func@?$ClassTemplate@_N@@QAEXXZ" |
| 1030 |
// G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN13ClassTemplateIbE4funcEv |
| 1031 |
// C32-DAG: define linkonce_odr dso_local void @_ZN13ClassTemplateIbE4funcEv |
| 1032 |
// PS-DAG: declare dllimport void @_ZN13ClassTemplateIbE4funcEv |
| 1033 |
|
| 1034 |
// Base class already specialized without dll attribute. |
| 1035 |
struct __declspec(dllexport) DerivedFromExplicitlySpecializedTemplate : public ExplicitlySpecializedTemplate<int> {}; |
| 1036 |
USEMEMFUNC(DerivedFromExplicitlySpecializedTemplate, func) |
| 1037 |
// M32-DAG: define dso_local x86_thiscallcc void @"?func@?$ExplicitlySpecializedTemplate@H@@QAEXXZ" |
| 1038 |
// G32-DAG: define dso_local x86_thiscallcc void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv |
| 1039 |
// C32-DAG: define dso_local void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv |
| 1040 |
// PS-DAG: define dso_local void @_ZN29ExplicitlySpecializedTemplateIiE4funcEv |
| 1041 |
|
| 1042 |
// Base class alredy specialized with export attribute. |
| 1043 |
struct __declspec(dllexport) DerivedFromExplicitlyExportSpecializedTemplate : public ExplicitlyExportSpecializedTemplate<int> {}; |
| 1044 |
USEMEMFUNC(DerivedFromExplicitlyExportSpecializedTemplate, func) |
| 1045 |
// M32-DAG: define dso_local dllexport x86_thiscallcc void @"?func@?$ExplicitlyExportSpecializedTemplate@H@@QAEXXZ" |
| 1046 |
// G32-DAG: define dso_local dllexport x86_thiscallcc void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv |
| 1047 |
// C32-DAG: define dso_local dllexport void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv |
| 1048 |
// PS-DAG: define dso_local dllexport void @_ZN35ExplicitlyExportSpecializedTemplateIiE4funcEv |
| 1049 |
|
| 1050 |
// Base class already specialized with import attribute. |
| 1051 |
struct __declspec(dllexport) DerivedFromExplicitlyImportSpecializedTemplate : public ExplicitlyImportSpecializedTemplate<int> {}; |
| 1052 |
USEMEMFUNC(DerivedFromExplicitlyImportSpecializedTemplate, func) |
| 1053 |
// M32-DAG: declare dllimport x86_thiscallcc void @"?func@?$ExplicitlyImportSpecializedTemplate@H@@QAEXXZ" |
| 1054 |
// G32-DAG: declare dllimport x86_thiscallcc void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv |
| 1055 |
// C32-DAG: declare dllimport void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv |
| 1056 |
// PS-DAG: declare dllimport void @_ZN35ExplicitlyImportSpecializedTemplateIiE4funcEv |
| 1057 |
|
| 1058 |
// Base class already instantiated without dll attribute. |
| 1059 |
struct __declspec(dllexport) DerivedFromExplicitlyInstantiatedTemplate : public ExplicitlyInstantiatedTemplate<int> {}; |
| 1060 |
USEMEMFUNC(DerivedFromExplicitlyInstantiatedTemplate, func) |
| 1061 |
// M32-DAG: define weak_odr dso_local x86_thiscallcc void @"?func@?$ExplicitlyInstantiatedTemplate@H@@QAEXXZ" |
| 1062 |
// G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv |
| 1063 |
// C32-DAG: define weak_odr dso_local void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv |
| 1064 |
// PS-DAG: define weak_odr void @_ZN30ExplicitlyInstantiatedTemplateIiE4funcEv |
| 1065 |
|
| 1066 |
// Base class already instantiated with export attribute. |
| 1067 |
struct __declspec(dllexport) DerivedFromExplicitlyExportInstantiatedTemplate : public ExplicitlyExportInstantiatedTemplate<int> {}; |
| 1068 |
USEMEMFUNC(DerivedFromExplicitlyExportInstantiatedTemplate, func) |
| 1069 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ExplicitlyExportInstantiatedTemplate@H@@QAEXXZ" |
| 1070 |
// G32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv |
| 1071 |
// C32-DAG: define weak_odr dso_local dllexport void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv |
| 1072 |
// PS-DAG: define weak_odr dllexport void @_ZN36ExplicitlyExportInstantiatedTemplateIiE4funcEv |
| 1073 |
|
| 1074 |
// Base class already instantiated with import attribute. |
| 1075 |
struct __declspec(dllexport) DerivedFromExplicitlyImportInstantiatedTemplate : public ExplicitlyImportInstantiatedTemplate<int> {}; |
| 1076 |
USEMEMFUNC(DerivedFromExplicitlyImportInstantiatedTemplate, func) |
| 1077 |
// M32-DAG: declare dllimport x86_thiscallcc void @"?func@?$ExplicitlyImportInstantiatedTemplate@H@@QAEXXZ" |
| 1078 |
// G32-DAG: declare dllimport x86_thiscallcc void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv |
| 1079 |
// C32-DAG: declare dllimport void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv |
| 1080 |
// PS-DAG: declare dllimport void @_ZN36ExplicitlyImportInstantiatedTemplateIiE4funcEv |
| 1081 |
|
| 1082 |
// MS: A dll attribute propagates through multiple levels of instantiation. |
| 1083 |
template <typename T> struct TopClass { void func() {} }; |
| 1084 |
template <typename T> struct MiddleClass : public TopClass<T> { }; |
| 1085 |
struct __declspec(dllexport) BottomClass : public MiddleClass<int> { }; |
| 1086 |
USEMEMFUNC(BottomClass, func) |
| 1087 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$TopClass@H@@QAEXXZ" |
| 1088 |
// G32-DAG: define linkonce_odr dso_local x86_thiscallcc void @_ZN8TopClassIiE4funcEv |
| 1089 |
// C32-DAG: define linkonce_odr dso_local void @_ZN8TopClassIiE4funcEv |
| 1090 |
// PS-DAG: define weak_odr dllexport void @_ZN8TopClassIiE4funcEv |
| 1091 |
|
| 1092 |
template <typename T> struct ExplicitInstantiationDeclTemplateBase { void func() {} }; |
| 1093 |
extern template struct ExplicitInstantiationDeclTemplateBase<int>; |
| 1094 |
struct __declspec(dllexport) DerivedFromExplicitInstantiationDeclTemplateBase : public ExplicitInstantiationDeclTemplateBase<int> {}; |
| 1095 |
template struct ExplicitInstantiationDeclTemplateBase<int>; |
| 1096 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc void @"?func@?$ExplicitInstantiationDeclTemplateBase@H@@QAEXXZ" |
| 1097 |
// G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv |
| 1098 |
// C32-DAG: define weak_odr dso_local void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv |
| 1099 |
// PS-DAG: define weak_odr dllexport void @_ZN37ExplicitInstantiationDeclTemplateBaseIiE4funcEv |
| 1100 |
|
| 1101 |
// PR26076 |
| 1102 |
struct LayerSelectionBound; |
| 1103 |
template <typename> struct Selection {}; |
| 1104 |
typedef Selection<LayerSelectionBound> LayerSelection; |
| 1105 |
struct LayerImpl; |
| 1106 |
struct __declspec(dllexport) LayerTreeImpl { |
| 1107 |
struct __declspec(dllexport) ElementLayers { |
| 1108 |
LayerImpl *main = nullptr; |
| 1109 |
}; |
| 1110 |
LayerSelection foo; |
| 1111 |
}; |
| 1112 |
// M32-DAG: define weak_odr dso_local dllexport x86_thiscallcc ptr @"??0ElementLayers@LayerTreeImpl@@QAE@XZ" |
| 1113 |
// M64-DAG: define weak_odr dso_local dllexport ptr @"??0ElementLayers@LayerTreeImpl@@QEAA@XZ" |
| 1114 |
|
| 1115 |
namespace pr39496 { |
| 1116 |
// Make sure dll attribute are inherited by static locals also in template |
| 1117 |
// specializations. |
| 1118 |
template <typename> struct __declspec(dllexport) S { int foo() { static int x; return x++; } }; |
| 1119 |
int foo() { S<int> s; return s.foo(); } |
| 1120 |
// 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 |
| 1121 |
|
| 1122 |
template <typename> struct T { int foo() { static int x; return x++; } }; |
| 1123 |
template struct __declspec(dllexport) T<int>; |
| 1124 |
// 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 |
| 1125 |
} |
| 1126 |
|
| 1127 |
class __declspec(dllexport) ACE_Shared_Object { |
| 1128 |
public: |
| 1129 |
virtual ~ACE_Shared_Object(); |
| 1130 |
}; |
| 1131 |
class __declspec(dllexport) ACE_Service_Object : public ACE_Shared_Object {}; |
| 1132 |
// Implicit move constructor declaration. |
| 1133 |
// MSVC2015-DAG: define weak_odr dso_local dllexport {{.+}}ACE_Service_Object@@Q{{.+}}@$$Q |
| 1134 |
// PS-DAG: define weak_odr dllexport void @_ZN18ACE_Service_ObjectC1EOS_ |
| 1135 |
// The declarations should not be exported. |
| 1136 |
// MSVC2013-NOT: define weak_odr dso_local dllexport {{.+}}ACE_Service_Object@@Q{{.+}}@$$Q |