blob: 20da1f631809ddfb2ca33aff70ca545535f7f435 [file] [log] [blame]
Stephen Hines651f13c2014-04-23 16:59:28 -07001// 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
Anders Carlsson48eda2c2009-12-04 22:35:50 +00003// CHECK: ; ModuleID
4
5struct A {
6 inline void f();
7};
8
Stephen Hines651f13c2014-04-23 16:59:28 -07009// CHECK-NOT: define void @_ZN1A1fEv
Anders Carlsson48eda2c2009-12-04 22:35:50 +000010void A::f() { }
11
12template<typename> struct B { };
13
14template<> struct B<char> {
15 inline void f();
16};
17
18// CHECK-NOT: _ZN1BIcE1fEv
19void B<char>::f() { }
20
21// We need a final CHECK line here.
22
Stephen Lin93ab6bf2013-08-15 06:47:53 +000023// CHECK-LABEL: define void @_Z1fv
Anders Carlsson48eda2c2009-12-04 22:35:50 +000024void f() { }
Douglas Gregor8f150942010-12-09 16:59:22 +000025
26// <rdar://problem/8740363>
27inline void f1(int);
28
Stephen Lin93ab6bf2013-08-15 06:47:53 +000029// CHECK-LABEL: define linkonce_odr void @_Z2f1i
Douglas Gregor8f150942010-12-09 16:59:22 +000030void f1(int) { }
31
32void test_f1() { f1(17); }
John McCallbfdcdc82010-12-15 04:00:32 +000033
34// PR8789
35namespace test1 {
36 template <typename T> class ClassTemplate {
37 private:
38 friend void T::func();
39 void g() {}
40 };
41
Stephen Lin93ab6bf2013-08-15 06:47:53 +000042 // CHECK-LABEL: define linkonce_odr void @_ZN5test11C4funcEv(
John McCallbfdcdc82010-12-15 04:00:32 +000043
44 class C {
45 public:
46 void func() {
47 ClassTemplate<C> ct;
48 ct.g();
49 }
50 };
51
52 void f() {
53 C c;
54 c.func();
55 }
56}
Eli Friedmanb135f0f2012-07-02 21:05:30 +000057
58// PR13252
59namespace test2 {
60 struct A;
61 void f(const A& a);
62 struct A {
63 friend void f(const A& a) { }
64 };
65 void g() {
66 A a;
67 f(a);
68 }
Stephen Lin93ab6bf2013-08-15 06:47:53 +000069 // CHECK-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE
Eli Friedmanb135f0f2012-07-02 21:05:30 +000070}
Stephen Hines651f13c2014-04-23 16:59:28 -070071
72// MSVCCOMPAT-LABEL: define weak_odr void @_Z17ExternAndInlineFnv
73// NORMAL-NOT: _Z17ExternAndInlineFnv
74extern inline void ExternAndInlineFn() {}
75
76// MSVCCOMPAT-LABEL: define weak_odr void @_Z18InlineThenExternFnv
77// NORMAL-NOT: _Z18InlineThenExternFnv
78inline void InlineThenExternFn() {}
79extern void InlineThenExternFn();
80
81// CHECK-LABEL: define void @_Z18ExternThenInlineFnv
82extern void ExternThenInlineFn() {}
83
84// MSVCCOMPAT-LABEL: define weak_odr void @_Z25ExternThenInlineThenDefFnv
85// NORMAL-NOT: _Z25ExternThenInlineThenDefFnv
86extern void ExternThenInlineThenDefFn();
87inline void ExternThenInlineThenDefFn();
88void ExternThenInlineThenDefFn() {}
89
90// MSVCCOMPAT-LABEL: define weak_odr void @_Z25InlineThenExternThenDefFnv
91// NORMAL-NOT: _Z25InlineThenExternThenDefFnv
92inline void InlineThenExternThenDefFn();
93extern void InlineThenExternThenDefFn();
94void InlineThenExternThenDefFn() {}
95
96// MSVCCOMPAT-LABEL: define weak_odr i32 @_Z20ExternAndConstexprFnv
97// NORMAL-NOT: _Z17ExternAndConstexprFnv
98extern constexpr int ExternAndConstexprFn() { return 0; }
99
100// CHECK-NOT: _Z11ConstexprFnv
101constexpr int ConstexprFn() { return 0; }
102
103template <typename T>
104extern inline void ExternInlineOnPrimaryTemplate(T);
105
106// CHECK-LABEL: define void @_Z29ExternInlineOnPrimaryTemplateIiEvT_
107template <>
108void ExternInlineOnPrimaryTemplate(int) {}
109
110template <typename T>
111extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(T);
112
113// MSVCCOMPAT-LABEL: define weak_odr void @_Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_
114// NORMAL-NOT: _Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_
115template <>
116extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {}
117
118struct TypeWithInlineMethods {
119 // CHECK-NOT: _ZN21TypeWithInlineMethods9StaticFunEv
120 static void StaticFun() {}
121 // CHECK-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv
122 void NonStaticFun() { StaticFun(); }
123};
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700124
125namespace PR22959 {
126template <typename>
127struct S;
128
129S<int> Foo();
130
131template <typename>
132struct S {
133 friend S<int> Foo();
134};
135
136__attribute__((used)) inline S<int> Foo() { return S<int>(); }
137// CHECK-LABEL: define linkonce_odr void @_ZN7PR229593FooEv(
138}