Skip to content

Commit 3234c26

Browse files
committed
pretest
1 parent 9036e23 commit 3234c26

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// RUN: %clang_cc1 -triple x86_64-win32 -fms-extensions -emit-llvm -o - %s | FileCheck %s --check-prefixes=MSC --implicit-check-not=to_be_
2+
// RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm -o - %s | FileCheck %s --check-prefixes=GNU --implicit-check-not=to_be_
3+
// RUN: %clang_cc1 -triple x86_64-cygwin -emit-llvm -o - %s | FileCheck %s --check-prefixes=GNU --implicit-check-not=to_be_
4+
5+
// Test that __declspec(dllexport) doesn't instantiate entities marked with
6+
// the exclude_from_explicit_instantiation attribute unless marked as dllexport explicitly.
7+
8+
#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
9+
10+
template <class T>
11+
struct C {
12+
// This will be instantiated explicitly as an exported function because it
13+
// inherits dllexport from the class instantiation.
14+
void to_be_exported() noexcept;
15+
16+
// This will be instantiated implicitly as an exported function because it is
17+
// marked as dllexport explicitly.
18+
EXCLUDE_FROM_EXPLICIT_INSTANTIATION __declspec(dllexport) void to_be_exported_explicitly() noexcept;
19+
20+
// This will be instantiated implicitly as an exported function unintentionally.
21+
EXCLUDE_FROM_EXPLICIT_INSTANTIATION void not_to_be_exported() noexcept;
22+
23+
// This won't be instantiated.
24+
EXCLUDE_FROM_EXPLICIT_INSTANTIATION void not_to_be_instantiated() noexcept;
25+
};
26+
27+
template <class T> void C<T>::to_be_exported() noexcept {}
28+
template <class T> void C<T>::to_be_exported_explicitly() noexcept {}
29+
template <class T> void C<T>::not_to_be_exported() noexcept {}
30+
template <class T> void C<T>::not_to_be_instantiated() noexcept {}
31+
32+
// MSC: $"?to_be_exported@?$C@H@@QEAAXXZ" = comdat any
33+
// MSC: $"?to_be_exported_explicitly@?$C@H@@QEAAXXZ" = comdat any
34+
// MSC: $"?not_to_be_exported@?$C@H@@QEAAXXZ" = comdat any
35+
// MSC: $"?not_to_be_instantiated@?$C@H@@QEAAXXZ" = comdat any
36+
// GNU: $_ZN1CIiE14to_be_exportedEv = comdat any
37+
// GNU: $_ZN1CIiE25to_be_exported_explicitlyEv = comdat any
38+
// GNU: $_ZN1CIiE18not_to_be_exportedEv = comdat any
39+
// GNU: $_ZN1CIiE22not_to_be_instantiatedEv = comdat any
40+
41+
// MSC: define weak_odr dso_local dllexport{{.*}} void @"?to_be_exported@?$C@H@@QEAAXXZ"
42+
// GNU: define weak_odr dso_local dllexport{{.*}} void @_ZN1CIiE14to_be_exportedEv
43+
template struct __declspec(dllexport) C<int>;
44+
45+
void use() {
46+
C<int> c;
47+
48+
// MSC: call void @"?to_be_exported_explicitly@?$C@H@@QEAAXXZ"
49+
// GNU: call void @_ZN1CIiE25to_be_exported_explicitlyEv
50+
c.to_be_exported_explicitly(); // implicitly instantiated here
51+
52+
// MSC: call void @"?not_to_be_exported@?$C@H@@QEAAXXZ"
53+
// GNU: call void @_ZN1CIiE18not_to_be_exportedEv
54+
c.not_to_be_exported(); // implicitly instantiated here
55+
};
56+
57+
// MSC: define weak_odr dso_local dllexport{{.*}} void @"?to_be_exported_explicitly@?$C@H@@QEAAXXZ"
58+
// GNU: define weak_odr dso_local dllexport{{.*}} void @_ZN1CIiE25to_be_exported_explicitlyEv
59+
60+
// MSC: define weak_odr dso_local dllexport void @"?not_to_be_exported@?$C@H@@QEAAXXZ"
61+
// GNU: define weak_odr dso_local dllexport void @_ZN1CIiE18not_to_be_exportedEv
62+
63+
// MSC: define weak_odr dso_local dllexport void @"?not_to_be_instantiated@?$C@H@@QEAAXXZ"
64+
// GNU: define weak_odr dso_local dllexport void @_ZN1CIiE22not_to_be_instantiatedEv
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// RUN: %clang_cc1 -triple x86_64-win32 -fms-extensions -emit-llvm -o - %s | FileCheck %s --check-prefixes=MSC --implicit-check-not=to_be_
2+
// RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm -o - %s | FileCheck %s --check-prefixes=GNU --implicit-check-not=to_be_
3+
// RUN: %clang_cc1 -triple x86_64-cygwin -emit-llvm -o - %s | FileCheck %s --check-prefixes=GNU --implicit-check-not=to_be_
4+
5+
// Test that __declspec(dllimport) doesn't instantiate entities marked with
6+
// the exclude_from_explicit_instantiation attribute unless marked as dllimport explicitly.
7+
8+
#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((exclude_from_explicit_instantiation))
9+
10+
template <class T>
11+
struct C {
12+
// This will be instantiated explicitly as an imported function because it
13+
// inherits dllimport from the class instantiation.
14+
void to_be_imported() noexcept;
15+
16+
// Per-member dllimport in explicitly dllimport-ed template instantiation is not allowed.
17+
//EXCLUDE_FROM_EXPLICIT_INSTANTIATION __declspec(dllimport) void to_be_imported_explicitly() noexcept;
18+
19+
// This will be instantiated implicitly as an imported function unintentionally.
20+
EXCLUDE_FROM_EXPLICIT_INSTANTIATION void not_to_be_imported() noexcept;
21+
22+
// This won't be instantiated.
23+
EXCLUDE_FROM_EXPLICIT_INSTANTIATION void not_to_be_instantiated() noexcept;
24+
};
25+
26+
template <class T> void C<T>::to_be_imported() noexcept {}
27+
template <class T> void C<T>::not_to_be_imported() noexcept {}
28+
template <class T> void C<T>::not_to_be_instantiated() noexcept {}
29+
30+
extern template struct __declspec(dllimport) C<int>;
31+
32+
void use() {
33+
C<int> c;
34+
35+
// MSC: call void @"?to_be_imported@?$C@H@@QEAAXXZ"
36+
// GNU: call void @_ZN1CIiE14to_be_importedEv
37+
c.to_be_imported();
38+
39+
//c.to_be_imported_explicitly();
40+
41+
// MSC: call void @"?not_to_be_imported@?$C@H@@QEAAXXZ"
42+
// GNU: call void @_ZN1CIiE18not_to_be_importedEv
43+
c.not_to_be_imported(); // implicitly instantiated here
44+
};
45+
46+
// MSC: declare dllimport void @"?to_be_imported@?$C@H@@QEAAXXZ"
47+
// GNU: declare dllimport void @_ZN1CIiE14to_be_importedEv
48+
49+
// MSC: declare dllimport void @"?not_to_be_imported@?$C@H@@QEAAXXZ"
50+
// GNU: declare dllimport void @_ZN1CIiE18not_to_be_importedEv

0 commit comments

Comments
 (0)