1 // RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NORMAL
2 // RUN: %clang_cc1 %s -std=c++11 -fms-compatibility -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=MSVCCOMPAT
3 // CHECK: ; ModuleID
4 
5 struct A {
6     inline void f();
7 };
8 
9 // CHECK-NOT: define void @_ZN1A1fEv
f()10 void A::f() { }
11 
12 template<typename> struct B { };
13 
14 template<> struct B<char> {
15   inline void f();
16 };
17 
18 // CHECK-NOT: _ZN1BIcE1fEv
f()19 void B<char>::f() { }
20 
21 // We need a final CHECK line here.
22 
23 // CHECK-LABEL: define void @_Z1fv
f()24 void f() { }
25 
26 // <rdar://problem/8740363>
27 inline void f1(int);
28 
29 // CHECK-LABEL: define linkonce_odr void @_Z2f1i
f1(int)30 void f1(int) { }
31 
test_f1()32 void test_f1() { f1(17); }
33 
34 // PR8789
35 namespace test1 {
36   template <typename T> class ClassTemplate {
37   private:
38     friend void T::func();
g()39     void g() {}
40   };
41 
42   // CHECK-LABEL: define linkonce_odr void @_ZN5test11C4funcEv(
43 
44   class C {
45   public:
func()46     void func() {
47       ClassTemplate<C> ct;
48       ct.g();
49     }
50   };
51 
f()52   void f() {
53     C c;
54     c.func();
55   }
56 }
57 
58 // PR13252
59 namespace test2 {
60   struct A;
61   void f(const A& a);
62   struct A {
f(const A & a)63     friend void f(const A& a) { }
64   };
g()65   void g() {
66     A a;
67     f(a);
68   }
69   // CHECK-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE
70 }
71 
72 // MSVCCOMPAT-LABEL: define weak_odr void @_Z17ExternAndInlineFnv
73 // NORMAL-NOT: _Z17ExternAndInlineFnv
ExternAndInlineFn()74 extern inline void ExternAndInlineFn() {}
75 
76 // MSVCCOMPAT-LABEL: define weak_odr void @_Z18InlineThenExternFnv
77 // NORMAL-NOT: _Z18InlineThenExternFnv
InlineThenExternFn()78 inline void InlineThenExternFn() {}
79 extern void InlineThenExternFn();
80 
81 // CHECK-LABEL: define void @_Z18ExternThenInlineFnv
ExternThenInlineFn()82 extern void ExternThenInlineFn() {}
83 
84 // MSVCCOMPAT-LABEL: define weak_odr void @_Z25ExternThenInlineThenDefFnv
85 // NORMAL-NOT: _Z25ExternThenInlineThenDefFnv
86 extern void ExternThenInlineThenDefFn();
87 inline void ExternThenInlineThenDefFn();
ExternThenInlineThenDefFn()88 void ExternThenInlineThenDefFn() {}
89 
90 // MSVCCOMPAT-LABEL: define weak_odr void @_Z25InlineThenExternThenDefFnv
91 // NORMAL-NOT: _Z25InlineThenExternThenDefFnv
92 inline void InlineThenExternThenDefFn();
93 extern void InlineThenExternThenDefFn();
InlineThenExternThenDefFn()94 void InlineThenExternThenDefFn() {}
95 
96 // MSVCCOMPAT-LABEL: define weak_odr i32 @_Z20ExternAndConstexprFnv
97 // NORMAL-NOT: _Z17ExternAndConstexprFnv
ExternAndConstexprFn()98 extern constexpr int ExternAndConstexprFn() { return 0; }
99 
100 // CHECK-NOT: _Z11ConstexprFnv
ConstexprFn()101 constexpr int ConstexprFn() { return 0; }
102 
103 template <typename T>
104 extern inline void ExternInlineOnPrimaryTemplate(T);
105 
106 // CHECK-LABEL: define void @_Z29ExternInlineOnPrimaryTemplateIiEvT_
107 template <>
ExternInlineOnPrimaryTemplate(int)108 void ExternInlineOnPrimaryTemplate(int) {}
109 
110 template <typename T>
111 extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(T);
112 
113 // MSVCCOMPAT-LABEL: define weak_odr void @_Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_
114 // NORMAL-NOT: _Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_
115 template <>
ExternInlineOnPrimaryTemplateAndSpecialization(int)116 extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {}
117 
118 struct TypeWithInlineMethods {
119   // CHECK-NOT: _ZN21TypeWithInlineMethods9StaticFunEv
StaticFunTypeWithInlineMethods120   static void StaticFun() {}
121   // CHECK-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv
NonStaticFunTypeWithInlineMethods122   void NonStaticFun() { StaticFun(); }
123 };
124 
125 namespace PR22959 {
126 template <typename>
127 struct S;
128 
129 S<int> Foo();
130 
131 template <typename>
132 struct S {
133   friend S<int> Foo();
134 };
135 
Foo()136 __attribute__((used)) inline S<int> Foo() { return S<int>(); }
137 // CHECK-LABEL: define linkonce_odr void @_ZN7PR229593FooEv(
138 }
139