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