Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 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 |
Anders Carlsson | 48eda2c | 2009-12-04 22:35:50 +0000 | [diff] [blame] | 3 | // CHECK: ; ModuleID |
| 4 | |
| 5 | struct A { |
| 6 | inline void f(); |
| 7 | }; |
| 8 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 9 | // CHECK-NOT: define void @_ZN1A1fEv |
Anders Carlsson | 48eda2c | 2009-12-04 22:35:50 +0000 | [diff] [blame] | 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 |
| 19 | void B<char>::f() { } |
| 20 | |
| 21 | // We need a final CHECK line here. |
| 22 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 23 | // CHECK-LABEL: define void @_Z1fv |
Anders Carlsson | 48eda2c | 2009-12-04 22:35:50 +0000 | [diff] [blame] | 24 | void f() { } |
Douglas Gregor | 8f15094 | 2010-12-09 16:59:22 +0000 | [diff] [blame] | 25 | |
| 26 | // <rdar://problem/8740363> |
| 27 | inline void f1(int); |
| 28 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 29 | // CHECK-LABEL: define linkonce_odr void @_Z2f1i |
Douglas Gregor | 8f15094 | 2010-12-09 16:59:22 +0000 | [diff] [blame] | 30 | void f1(int) { } |
| 31 | |
| 32 | void test_f1() { f1(17); } |
John McCall | bfdcdc8 | 2010-12-15 04:00:32 +0000 | [diff] [blame] | 33 | |
| 34 | // PR8789 |
| 35 | namespace test1 { |
| 36 | template <typename T> class ClassTemplate { |
| 37 | private: |
| 38 | friend void T::func(); |
| 39 | void g() {} |
| 40 | }; |
| 41 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 42 | // CHECK-LABEL: define linkonce_odr void @_ZN5test11C4funcEv( |
John McCall | bfdcdc8 | 2010-12-15 04:00:32 +0000 | [diff] [blame] | 43 | |
| 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 Friedman | b135f0f | 2012-07-02 21:05:30 +0000 | [diff] [blame] | 57 | |
| 58 | // PR13252 |
| 59 | namespace 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 Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 69 | // CHECK-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE |
Eli Friedman | b135f0f | 2012-07-02 21:05:30 +0000 | [diff] [blame] | 70 | } |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 71 | |
| 72 | // MSVCCOMPAT-LABEL: define weak_odr void @_Z17ExternAndInlineFnv |
| 73 | // NORMAL-NOT: _Z17ExternAndInlineFnv |
| 74 | extern inline void ExternAndInlineFn() {} |
| 75 | |
| 76 | // MSVCCOMPAT-LABEL: define weak_odr void @_Z18InlineThenExternFnv |
| 77 | // NORMAL-NOT: _Z18InlineThenExternFnv |
| 78 | inline void InlineThenExternFn() {} |
| 79 | extern void InlineThenExternFn(); |
| 80 | |
| 81 | // CHECK-LABEL: define void @_Z18ExternThenInlineFnv |
| 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(); |
| 88 | void ExternThenInlineThenDefFn() {} |
| 89 | |
| 90 | // MSVCCOMPAT-LABEL: define weak_odr void @_Z25InlineThenExternThenDefFnv |
| 91 | // NORMAL-NOT: _Z25InlineThenExternThenDefFnv |
| 92 | inline void InlineThenExternThenDefFn(); |
| 93 | extern void InlineThenExternThenDefFn(); |
| 94 | void InlineThenExternThenDefFn() {} |
| 95 | |
| 96 | // MSVCCOMPAT-LABEL: define weak_odr i32 @_Z20ExternAndConstexprFnv |
| 97 | // NORMAL-NOT: _Z17ExternAndConstexprFnv |
| 98 | extern constexpr int ExternAndConstexprFn() { return 0; } |
| 99 | |
| 100 | // CHECK-NOT: _Z11ConstexprFnv |
| 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 <> |
| 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 <> |
| 116 | extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {} |
| 117 | |
| 118 | struct TypeWithInlineMethods { |
| 119 | // CHECK-NOT: _ZN21TypeWithInlineMethods9StaticFunEv |
| 120 | static void StaticFun() {} |
| 121 | // CHECK-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv |
| 122 | void NonStaticFun() { StaticFun(); } |
| 123 | }; |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame^] | 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 | |
| 136 | __attribute__((used)) inline S<int> Foo() { return S<int>(); } |
| 137 | // CHECK-LABEL: define linkonce_odr void @_ZN7PR229593FooEv( |
| 138 | } |