1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes -emit-llvm -std=c++11 -o - %s | FileCheck %s
2
3 template<typename T>
4 struct X0 {
fX05 void f(T &t) {
6 t = 0;
7 }
8
9 void g(T &t);
10
11 void h(T &t);
12
13 static T static_var;
14 };
15
16 template<typename T>
g(T & t)17 inline void X0<T>::g(T & t) {
18 t = 0;
19 }
20
21 template<typename T>
h(T & t)22 void X0<T>::h(T & t) {
23 t = 0;
24 }
25
26 template<typename T>
27 T X0<T>::static_var = 0;
28
29 extern template struct X0<int*>;
30
test(X0<int * > xi,int * ip)31 int *&test(X0<int*> xi, int *ip) {
32 // CHECK: define available_externally void @_ZN2X0IPiE1fERS0_
33 xi.f(ip);
34 // CHECK: define available_externally void @_ZN2X0IPiE1gERS0_
35 xi.g(ip);
36 // CHECK: declare void @_ZN2X0IPiE1hERS0_
37 xi.h(ip);
38 return X0<int*>::static_var;
39 }
40
41 template<typename T>
f0(T & t)42 void f0(T& t) {
43 t = 0;
44 }
45
46 template<typename T>
f1(T & t)47 inline void f1(T& t) {
48 t = 0;
49 }
50
51 extern template void f0<>(int *&);
52 extern template void f1<>(int *&);
53
test_f0(int * ip,float * fp)54 void test_f0(int *ip, float *fp) {
55 // CHECK: declare void @_Z2f0IPiEvRT_
56 f0(ip);
57 // CHECK: define linkonce_odr void @_Z2f0IPfEvRT_
58 f0(fp);
59 }
60
test_f1(int * ip,float * fp)61 void test_f1(int *ip, float *fp) {
62 // CHECK: define available_externally void @_Z2f1IPiEvRT_
63 f1(ip);
64 // CHECK: define linkonce_odr void @_Z2f1IPfEvRT_
65 f1(fp);
66 }
67