Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / pragma-visibility.cpp
blob2300d0a3c5dae7947953753d746041c2da611687
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
3 #pragma GCC visibility push(hidden)
4 struct x {
5 static int y;
6 };
7 #pragma GCC visibility pop
8 int x::y = 10;
9 // CHECK: @_ZN1x1yE = hidden global
11 #pragma GCC visibility push(hidden)
12 struct __attribute((visibility("default"))) x2 {
13 static int y;
15 int x2::y = 10;
16 // CHECK: @_ZN2x21yE ={{.*}} global
17 #pragma GCC visibility pop
19 #pragma GCC visibility push(hidden)
20 template<class T> struct x4 {
21 static int y;
23 #pragma GCC visibility pop
24 template<> int x4<int>::y = 10;
25 // CHECK: @_ZN2x4IiE1yE = hidden global i32
27 #pragma GCC visibility push(hidden)
28 template<int x> int f() { return x; }
29 extern "C" int g() { return f<3>(); }
30 #pragma GCC visibility pop
31 // CHECK-LABEL: define hidden i32 @g()
32 // CHECK-LABEL: define linkonce_odr hidden noundef i32 @_Z1fILi3EEiv()
34 #pragma GCC visibility push(hidden)
35 template<class T> struct x5 {
36 void y();
38 #pragma GCC visibility pop
39 template<> void x5<int>::y() {}
40 // CHECK-LABEL: define hidden void @_ZN2x5IiE1yEv
42 #pragma GCC visibility push(hidden)
43 namespace n __attribute((visibility("default"))) {
44 void f() {}
45 // CHECK-LABEL: define{{.*}} void @_ZN1n1fEv
47 #pragma GCC visibility pop
49 namespace n __attribute((visibility("default"))) {
50 #pragma GCC visibility push(hidden)
51 void g() {}
52 // CHECK-LABEL: define hidden void @_ZN1n1gEv
53 #pragma GCC visibility pop
56 namespace test2 {
57 #pragma GCC visibility push(default)
58 #pragma GCC visibility push(hidden)
59 struct foo { // foo is hidden
61 #pragma GCC visibility pop
62 struct foo; // declaration is ok, we ignore the default in the stack
63 template<typename T>
64 struct bar { // bar is default
65 static void f(){}
67 #pragma GCC visibility pop
68 void zed() {
69 bar<foo>::f();
70 bar<int>::f();
72 // CHECK-LABEL: define linkonce_odr hidden void @_ZN5test23barINS_3fooEE1fEv
73 // CHECK-LABEL: define linkonce_odr void @_ZN5test23barIiE1fEv