| 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-pc-win32 -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 |
// NORMAL-NOT: define{{.*}} void @_ZN1A1fEv |
| 10 |
// MSVCCOMPAT-NOT: define{{.*}} void @"?f@A@@QEAAXXZ" |
| 11 |
void A::f() { } |
| 12 |
|
| 13 |
template<typename> struct B { }; |
| 14 |
|
| 15 |
template<> struct B<char> { |
| 16 |
inline void f(); |
| 17 |
}; |
| 18 |
|
| 19 |
// NORMAL-NOT: _ZN1BIcE1fEv |
| 20 |
// MSVCCOMPAT-NOT: @"?f@?$B@D@@QEAAXXZ" |
| 21 |
void B<char>::f() { } |
| 22 |
|
| 23 |
// We need a final CHECK line here. |
| 24 |
|
| 25 |
// NORMAL-LABEL: define{{.*}} void @_Z1fv |
| 26 |
// MSVCCOMPAT-LABEL: define dso_local void @"?f@@YAXXZ" |
| 27 |
void f() { } |
| 28 |
|
| 29 |
inline void f1(int); |
| 30 |
|
| 31 |
// NORMAL-LABEL: define linkonce_odr void @_Z2f1i |
| 32 |
// MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?f1@@YAXH@Z" |
| 33 |
void f1(int) { } |
| 34 |
|
| 35 |
void test_f1() { f1(17); } |
| 36 |
|
| 37 |
// PR8789 |
| 38 |
namespace test1 { |
| 39 |
template <typename T> class ClassTemplate { |
| 40 |
private: |
| 41 |
friend void T::func(); |
| 42 |
void g() {} |
| 43 |
}; |
| 44 |
|
| 45 |
// NORMAL-LABEL: define linkonce_odr void @_ZN5test11C4funcEv( |
| 46 |
// MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?func@C@test1@@QEAAXXZ"( |
| 47 |
|
| 48 |
class C { |
| 49 |
public: |
| 50 |
void func() { |
| 51 |
ClassTemplate<C> ct; |
| 52 |
ct.g(); |
| 53 |
} |
| 54 |
}; |
| 55 |
|
| 56 |
void f() { |
| 57 |
C c; |
| 58 |
c.func(); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
// PR13252 |
| 63 |
namespace test2 { |
| 64 |
struct A; |
| 65 |
void f(const A& a); |
| 66 |
struct A { |
| 67 |
friend void f(const A& a) { } |
| 68 |
}; |
| 69 |
void g() { |
| 70 |
A a; |
| 71 |
f(a); |
| 72 |
} |
| 73 |
// NORMAL-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE |
| 74 |
// MSVCCOMPAT-LABEL: define linkonce_odr dso_local void @"?f@test2@@YAXAEBUA@1@@Z" |
| 75 |
} |
| 76 |
|
| 77 |
// NORMAL-NOT: _Z17ExternAndInlineFnv |
| 78 |
// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?ExternAndInlineFn@@YAXXZ" |
| 79 |
extern inline void ExternAndInlineFn() {} |
| 80 |
|
| 81 |
// NORMAL-NOT: _Z18InlineThenExternFnv |
| 82 |
// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?InlineThenExternFn@@YAXXZ" |
| 83 |
inline void InlineThenExternFn() {} |
| 84 |
extern void InlineThenExternFn(); |
| 85 |
|
| 86 |
// NORMAL-LABEL: define{{.*}} void @_Z18ExternThenInlineFnv |
| 87 |
// MSVCCOMPAT-LABEL: define dso_local void @"?ExternThenInlineFn@@YAXXZ" |
| 88 |
extern void ExternThenInlineFn() {} |
| 89 |
|
| 90 |
// NORMAL-NOT: _Z25ExternThenInlineThenDefFnv |
| 91 |
// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?ExternThenInlineThenDefFn@@YAXXZ" |
| 92 |
extern void ExternThenInlineThenDefFn(); |
| 93 |
inline void ExternThenInlineThenDefFn(); |
| 94 |
void ExternThenInlineThenDefFn() {} |
| 95 |
|
| 96 |
// NORMAL-NOT: _Z25InlineThenExternThenDefFnv |
| 97 |
// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"?InlineThenExternThenDefFn@@YAXXZ" |
| 98 |
inline void InlineThenExternThenDefFn(); |
| 99 |
extern void InlineThenExternThenDefFn(); |
| 100 |
void InlineThenExternThenDefFn() {} |
| 101 |
|
| 102 |
// NORMAL-NOT: _Z17ExternAndConstexprFnv |
| 103 |
// MSVCCOMPAT-LABEL: define weak_odr dso_local noundef i32 @"?ExternAndConstexprFn@@YAHXZ" |
| 104 |
extern constexpr int ExternAndConstexprFn() { return 0; } |
| 105 |
|
| 106 |
// NORMAL-NOT: _Z11ConstexprFnv |
| 107 |
// MSVCCOMPAT-NOT: @"?ConstexprFn@@YAHXZ" |
| 108 |
constexpr int ConstexprFn() { return 0; } |
| 109 |
|
| 110 |
template <typename T> |
| 111 |
extern inline void ExternInlineOnPrimaryTemplate(T); |
| 112 |
|
| 113 |
// NORMAL-LABEL: define{{.*}} void @_Z29ExternInlineOnPrimaryTemplateIiEvT_ |
| 114 |
// MSVCCOMPAT-LABEL: define dso_local void @"??$ExternInlineOnPrimaryTemplate@H@@YAXH@Z" |
| 115 |
template <> |
| 116 |
void ExternInlineOnPrimaryTemplate(int) {} |
| 117 |
|
| 118 |
template <typename T> |
| 119 |
extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(T); |
| 120 |
|
| 121 |
// NORMAL-NOT: _Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_ |
| 122 |
// MSVCCOMPAT-LABEL: define weak_odr dso_local void @"??$ExternInlineOnPrimaryTemplateAndSpecialization@H@@YAXH@Z" |
| 123 |
template <> |
| 124 |
extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {} |
| 125 |
|
| 126 |
struct TypeWithInlineMethods { |
| 127 |
// NORMAL-NOT: _ZN21TypeWithInlineMethods9StaticFunEv |
| 128 |
// MSVCCOMPAT-NOT: @"?StaticFun@TypeWithInlineMethods@@SAXXZ" |
| 129 |
static void StaticFun() {} |
| 130 |
// NORMAL-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv |
| 131 |
// MSVCCOMPAT-NOT: @"?NonStaticFun@TypeWithInlineMethods@@QEAAXXZ" |
| 132 |
void NonStaticFun() { StaticFun(); } |
| 133 |
}; |
| 134 |
|
| 135 |
namespace PR22959 { |
| 136 |
template <typename> |
| 137 |
struct S; |
| 138 |
|
| 139 |
S<int> Foo(); |
| 140 |
|
| 141 |
template <typename> |
| 142 |
struct S { |
| 143 |
friend S<int> Foo(); |
| 144 |
}; |
| 145 |
|
| 146 |
__attribute__((used)) inline S<int> Foo() { return S<int>(); } |
| 147 |
// NORMAL-LABEL: define linkonce_odr void @_ZN7PR229593FooEv( |
| 148 |
// MSVCCOMPAT-LABEL: define linkonce_odr dso_local i8 @"?Foo@PR22959@@YA?AU?$S@H@1@XZ"( |
| 149 |
} |