Add a "don't override" mapping for -fvisibility-from-dllstorageclass … · llvm/llvm-project@cd05ade (original) (raw)
1
1
`// REQUIRES: x86-registered-target
`
2
2
``
3
``
`-
// Test that -fvisibility-from-dllstorageclass maps DLL storage class to visibility
`
4
``
`-
// and that it overrides the effect of visibility options and annotations.
`
``
3
`+
//// Test that -fvisibility-from-dllstorageclass maps DLL storage class to visibility
`
``
4
`+
//// and that it overrides the effect of visibility options and annotations.
`
5
5
``
6
6
`// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
`
7
7
`// RUN: -fvisibility=hidden \
`
32
32
`// RUN: -x c++ %s -S -emit-llvm -o - | \
`
33
33
`// RUN: FileCheck %s --check-prefixes=ALL_DEFAULT
`
34
34
``
``
35
`+
// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
`
``
36
`+
// RUN: -fvisibility=hidden \
`
``
37
`+
// RUN: -fapply-global-visibility-to-externs \
`
``
38
`+
// RUN: -fvisibility-from-dllstorageclass \
`
``
39
`+
// RUN: -fvisibility-dllexport=keep \
`
``
40
`+
// RUN: -fvisibility-nodllstorageclass=keep \
`
``
41
`+
// RUN: -fvisibility-externs-dllimport=keep \
`
``
42
`+
// RUN: -fvisibility-externs-nodllstorageclass=keep \
`
``
43
`+
// RUN: -x c++ %s -S -emit-llvm -o - | \
`
``
44
`+
// RUN: FileCheck %s --check-prefixes=ALL_KEEP
`
``
45
+
``
46
`+
//// Show that omitting -fvisibility-from-dllstorageclass causes the other options to be ignored.
`
``
47
`+
// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
`
``
48
`+
// RUN: -fvisibility=hidden \
`
``
49
`+
// RUN: -fapply-global-visibility-to-externs \
`
``
50
`+
// RUN: -fvisibility-dllexport=protected \
`
``
51
`+
// RUN: -fvisibility-nodllstorageclass=protected \
`
``
52
`+
// RUN: -fvisibility-externs-dllimport=protected \
`
``
53
`+
// RUN: -fvisibility-externs-nodllstorageclass=protected \
`
``
54
`+
// RUN: -x c++ %s -S -emit-llvm -o - | \
`
``
55
`+
// RUN: FileCheck %s --check-prefixes=ALL_KEEP
`
``
56
+
35
57
`// Local
`
36
58
`static void l() {}
`
37
59
`void use_locals(){l();}
`
38
60
`// DEFAULTS-DAG: define internal void @_ZL1lv()
`
39
61
`// EXPLICIT-DAG: define internal void @_ZL1lv()
`
40
62
`// ALL_DEFAULT-DAG: define internal void @_ZL1lv()
`
``
63
`+
// ALL_KEEP-DAG: define internal void @_ZL1lv()
`
41
64
``
42
65
`// Function
`
43
66
`void f() {}
`
`@@ -48,6 +71,8 @@ void __declspec(dllexport) exported_f() {}
`
48
71
`// EXPLICIT-DAG: define hidden void @_Z10exported_fv()
`
49
72
`// ALL_DEFAULT-DAG: define void @_Z1fv()
`
50
73
`// ALL_DEFAULT-DAG: define void @_Z10exported_fv()
`
``
74
`+
// ALL_KEEP-DAG: define hidden void @_Z1fv()
`
``
75
`+
// ALL_KEEP-DAG: define hidden void @_Z10exported_fv()
`
51
76
``
52
77
`// Variable
`
53
78
`int d = 123;
`
`@@ -58,6 +83,8 @@ __declspec(dllexport) int exported_d = 123;
`
58
83
`// EXPLICIT-DAG: @exported_d = hidden global
`
59
84
`// ALL_DEFAULT-DAG: @d = global
`
60
85
`// ALL_DEFAULT-DAG: @exported_d = global
`
``
86
`+
// ALL_KEEP-DAG: @d = hidden global
`
``
87
`+
// ALL_KEEP-DAG: @exported_d = hidden global
`
61
88
``
62
89
`// Alias
`
63
90
`extern "C" void aliased() {}
`
`@@ -69,6 +96,8 @@ void __declspec(dllexport) a_exported() attribute((alias("aliased")));
`
69
96
`// EXPLICIT-DAG: @_Z10a_exportedv = hidden alias
`
70
97
`// ALL_DEFAULT-DAG: @_Z1av = alias
`
71
98
`// ALL_DEFAULT-DAG: @_Z10a_exportedv = alias
`
``
99
`+
// ALL_KEEP-DAG: @_Z1av = hidden alias
`
``
100
`+
// ALL_KEEP-DAG: @_Z10a_exportedv = dso_local alias
`
72
101
``
73
102
`// Declaration
`
74
103
`extern void e();
`
`@@ -79,6 +108,8 @@ extern void __declspec(dllimport) imported_e();
`
79
108
`// EXPLICIT-DAG: declare hidden void @_Z10imported_ev()
`
80
109
`// ALL_DEFAULT-DAG: declare void @_Z1ev()
`
81
110
`// ALL_DEFAULT-DAG: declare void @_Z10imported_ev()
`
``
111
`+
// ALL_KEEP-DAG: declare hidden void @_Z1ev()
`
``
112
`+
// ALL_KEEP-DAG: declare void @_Z10imported_ev()
`
82
113
``
83
114
`// Weak Declaration
`
84
115
`attribute((weak))
`
`@@ -91,6 +122,8 @@ extern void __declspec(dllimport) imported_w();
`
91
122
`// EXPLICIT-DAG: declare extern_weak hidden void @_Z10imported_wv()
`
92
123
`// ALL_DEFAULT-DAG: declare extern_weak void @_Z1wv()
`
93
124
`// ALL_DEFAULT-DAG: declare extern_weak void @_Z10imported_wv()
`
``
125
`+
// ALL_KEEP-DAG: declare extern_weak hidden void @_Z1wv()
`
``
126
`+
// ALL_KEEP-DAG: declare extern_weak void @_Z10imported_wv()
`
94
127
``
95
128
`void use_declarations(){e(); imported_e(); w(); imported_w();}
`
96
129
``
`@@ -101,11 +134,14 @@ struct attribute((type_visibility("protected"))) t {
`
101
134
`};
`
102
135
`void t::foo() {}
`
103
136
`// DEFAULTS-DAG: @_ZTV1t = hidden unnamed_addr constant
`
``
137
`+
// ALL_KEEP-DAG: @_ZTV1t = protected unnamed_addr constant
`
104
138
``
105
139
`int v attribute ((visibility ("protected"))) = 123;
`
106
140
`// DEFAULTS-DAG: @v = hidden global
`
``
141
`+
// ALL_KEEP-DAG: @v = protected global
`
107
142
``
108
143
`#pragma GCC visibility push(protected)
`
109
144
`int p = 345;
`
110
145
`#pragma GCC visibility pop
`
111
146
`// DEFAULTS-DAG: @p = hidden global
`
``
147
`+
// ALL_KEEP-DAG: @p = protected global
`