1 // RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 -fvisibility-inlines-hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
3 // The trickery with optimization in the run line is to get IR
4 // generation to emit available_externally function bodies, but not
5 // actually inline them (and thus remove the emitted bodies).
8 void __attribute__((visibility("default"))) f1() { }
15 inline void X0::f3() { }
19 void __attribute__((visibility("default"))) f1() { }
28 inline void X1
<T
>::f3() { }
31 inline void X1
<int>::f4() { }
33 struct __attribute__((visibility("default"))) X2
{
37 extern template struct X1
<float>;
39 void use(X0
*x0
, X1
<int> *x1
, X2
*x2
, X1
<float> *x3
) {
40 // CHECK-LABEL: define linkonce_odr void @_ZN2X02f1Ev
42 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X02f2Ev
44 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X02f3Ev
46 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X02f5Ev
48 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X02f6Ev
50 // CHECK-LABEL: define linkonce_odr void @_ZN2X1IiE2f1Ev
52 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X1IiE2f2Ev
54 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X1IiE2f3Ev
56 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X1IiE2f4Ev
58 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X1IiE2f5Ev
60 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X1IiE2f6Ev
62 // CHECK-LABEL: define linkonce_odr hidden void @_ZN2X22f2Ev
64 // CHECK-LABEL: define available_externally void @_ZN2X1IfE2f2Ev
69 struct __attribute__((visibility("default"))) A
{
78 // CHECK: declare void @_ZN5test11A3fooEv
79 // CHECK: declare {{.*}} @_ZN5test11AD1Ev
85 template <class T
> class B
{};
88 namespace ns
__attribute__((visibility("default"))) {
89 template <class T
> inline void foo() {}
90 extern template void foo
<arg
>();
97 // CHECK-LABEL: define available_externally void @_ZN5test22ns3fooINS_1BINS_1AEEEEEvv()
101 template <typename T
>
104 T
foo(T x
) { return x
; }
106 extern template class Foo
<int>;
107 template class Foo
<int>;
108 // CHECK-LABEL: define weak_odr noundef i32 @_ZN7PR116423FooIiE3fooEi
111 // Test that clang implements the new gcc behaviour for inline functions.
114 inline void foo(void) {
119 template void zed
<float>();
124 // CHECK-LABEL: define weak_odr void @_ZN5test33zedIfEEvv
125 // CHECK-LABEL: define linkonce_odr hidden void @_ZN5test33fooEv
126 // CHECK-LABEL: define linkonce_odr hidden void @_ZN5test33zedIiEEvv
130 extern inline __attribute__ ((__gnu_inline__
))
135 // CHECK-LABEL: define available_externally void @_ZN5test43fooE
140 template <int> inline void Op();
141 class UnaryInstruction
{
146 template <int Idx_nocapture
> void Op() {
152 template <typename T
>
166 template <typename T
> void tf() {}
168 // CHECK-LABEL: define linkonce_odr hidden noundef ptr @_ZN7PR348111fEv(
171 // CHECK-LABEL: define linkonce_odr hidden void @_ZN7PR348112tfIZNS_1fEvEUlvE_EEvv(
172 return (void *)&tf
<decltype(l
)>;