Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / visibility-ms-compat.cpp
blob525691358832f8781fc910c9e38f489e8b267bdb
1 // RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility=hidden -ftype-visibility=default -emit-llvm -o %t
2 // RUN: FileCheck %s < %t
3 // RUN: FileCheck -check-prefix=CHECK-GLOBAL %s < %t
5 // The two visibility options above are how we translate
6 // -fvisibility-ms-compat in the driver.
8 #define HIDDEN __attribute__((visibility("hidden")))
9 #define PROTECTED __attribute__((visibility("protected")))
10 #define DEFAULT __attribute__((visibility("default")))
12 namespace std {
13 class type_info;
16 namespace test0 {
17 struct A {
18 static void foo();
19 static void bar();
22 void A::foo() { bar(); }
23 // CHECK-LABEL: define hidden void @_ZN5test01A3fooEv()
24 // CHECK: declare void @_ZN5test01A3barEv()
26 const std::type_info &ti = typeid(A);
27 // CHECK-GLOBAL: @_ZTSN5test01AE = linkonce_odr constant
28 // CHECK-GLOBAL: @_ZTIN5test01AE = linkonce_odr constant
29 // CHECK-GLOBAL: @_ZN5test02tiE = hidden constant
32 namespace test1 {
33 struct HIDDEN A {
34 static void foo();
35 static void bar();
38 void A::foo() { bar(); }
39 // CHECK-LABEL: define hidden void @_ZN5test11A3fooEv()
40 // CHECK: declare hidden void @_ZN5test11A3barEv()
42 const std::type_info &ti = typeid(A);
43 // CHECK-GLOBAL: @_ZTSN5test11AE = linkonce_odr hidden constant
44 // CHECK-GLOBAL: @_ZTIN5test11AE = linkonce_odr hidden constant
45 // CHECK-GLOBAL: @_ZN5test12tiE = hidden constant
48 namespace test2 {
49 struct DEFAULT A {
50 static void foo();
51 static void bar();
54 void A::foo() { bar(); }
55 // CHECK-LABEL: define{{.*}} void @_ZN5test21A3fooEv()
56 // CHECK: declare void @_ZN5test21A3barEv()
58 const std::type_info &ti = typeid(A);
59 // CHECK-GLOBAL: @_ZTSN5test21AE = linkonce_odr constant
60 // CHECK-GLOBAL: @_ZTIN5test21AE = linkonce_odr constant
61 // CHECK-GLOBAL: @_ZN5test22tiE = hidden constant
64 namespace test3 {
65 struct A { int x; };
66 template <class T> struct B {
67 static void foo() { bar(); }
68 static void bar();
71 template void B<A>::foo();
72 // CHECK-LABEL: define weak_odr hidden void @_ZN5test31BINS_1AEE3fooEv()
73 // CHECK: declare void @_ZN5test31BINS_1AEE3barEv()
75 const std::type_info &ti = typeid(B<A>);
76 // CHECK-GLOBAL: @_ZTSN5test31BINS_1AEEE = linkonce_odr constant
77 // CHECK-GLOBAL: @_ZTIN5test31BINS_1AEEE = linkonce_odr constant
80 namespace test4 {
81 struct A { int x; };
82 template <class T> struct DEFAULT B {
83 static void foo() { bar(); }
84 static void bar();
87 template void B<A>::foo();
88 // CHECK-LABEL: define weak_odr void @_ZN5test41BINS_1AEE3fooEv()
89 // CHECK: declare void @_ZN5test41BINS_1AEE3barEv()
91 const std::type_info &ti = typeid(B<A>);
92 // CHECK-GLOBAL: @_ZTSN5test41BINS_1AEEE = linkonce_odr constant
93 // CHECK-GLOBAL: @_ZTIN5test41BINS_1AEEE = linkonce_odr constant
96 namespace test5 {
97 struct A { int x; };
98 template <class T> struct HIDDEN B {
99 static void foo() { bar(); }
100 static void bar();
103 template void B<A>::foo();
104 // CHECK-LABEL: define weak_odr hidden void @_ZN5test51BINS_1AEE3fooEv()
105 // CHECK: declare hidden void @_ZN5test51BINS_1AEE3barEv()
107 const std::type_info &ti = typeid(B<A>);
108 // CHECK-GLOBAL: @_ZTSN5test51BINS_1AEEE = linkonce_odr hidden constant
109 // CHECK-GLOBAL: @_ZTIN5test51BINS_1AEEE = linkonce_odr hidden constant