2014-04-03 07:17:29 +08:00
|
|
|
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s --check-prefix=CHECK --check-prefix=NORMAL
|
2015-10-08 12:53:31 +08:00
|
|
|
// 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
|
2009-12-05 06:35:50 +08:00
|
|
|
// CHECK: ; ModuleID
|
|
|
|
|
|
|
|
struct A {
|
|
|
|
inline void f();
|
|
|
|
};
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-NOT: define void @_ZN1A1fEv
|
|
|
|
// MSVCCOMPAT-NOT: define void @"\01?f@A@@QEAAXXZ"
|
2009-12-05 06:35:50 +08:00
|
|
|
void A::f() { }
|
|
|
|
|
|
|
|
template<typename> struct B { };
|
|
|
|
|
|
|
|
template<> struct B<char> {
|
|
|
|
inline void f();
|
|
|
|
};
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-NOT: _ZN1BIcE1fEv
|
|
|
|
// MSVCCOMPAT-NOT: @"\01?f@?$B@D@@QEAAXXZ"
|
2009-12-05 06:35:50 +08:00
|
|
|
void B<char>::f() { }
|
|
|
|
|
|
|
|
// We need a final CHECK line here.
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define void @_Z1fv
|
|
|
|
// MSVCCOMPAT-LABEL: define void @"\01?f@@YAXXZ"
|
2009-12-05 06:35:50 +08:00
|
|
|
void f() { }
|
2010-12-10 00:59:22 +08:00
|
|
|
|
|
|
|
// <rdar://problem/8740363>
|
|
|
|
inline void f1(int);
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define linkonce_odr void @_Z2f1i
|
|
|
|
// MSVCCOMPAT-LABEL: define linkonce_odr void @"\01?f1@@YAXH@Z"
|
2010-12-10 00:59:22 +08:00
|
|
|
void f1(int) { }
|
|
|
|
|
|
|
|
void test_f1() { f1(17); }
|
2010-12-15 12:00:32 +08:00
|
|
|
|
|
|
|
// PR8789
|
|
|
|
namespace test1 {
|
|
|
|
template <typename T> class ClassTemplate {
|
|
|
|
private:
|
|
|
|
friend void T::func();
|
|
|
|
void g() {}
|
|
|
|
};
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define linkonce_odr void @_ZN5test11C4funcEv(
|
|
|
|
// MSVCCOMPAT-LABEL: define linkonce_odr void @"\01?func@C@test1@@QEAAXXZ"(
|
2010-12-15 12:00:32 +08:00
|
|
|
|
|
|
|
class C {
|
|
|
|
public:
|
|
|
|
void func() {
|
|
|
|
ClassTemplate<C> ct;
|
|
|
|
ct.g();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
C c;
|
|
|
|
c.func();
|
|
|
|
}
|
|
|
|
}
|
2012-07-03 05:05:30 +08:00
|
|
|
|
|
|
|
// PR13252
|
|
|
|
namespace test2 {
|
|
|
|
struct A;
|
|
|
|
void f(const A& a);
|
|
|
|
struct A {
|
|
|
|
friend void f(const A& a) { }
|
|
|
|
};
|
|
|
|
void g() {
|
|
|
|
A a;
|
|
|
|
f(a);
|
|
|
|
}
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE
|
|
|
|
// MSVCCOMPAT-LABEL: define linkonce_odr void @"\01?f@test2@@YAXAEBUA@1@@Z"
|
2012-07-03 05:05:30 +08:00
|
|
|
}
|
2014-04-03 07:17:29 +08:00
|
|
|
|
|
|
|
// NORMAL-NOT: _Z17ExternAndInlineFnv
|
2015-10-08 12:53:31 +08:00
|
|
|
// MSVCCOMPAT-LABEL: define weak_odr void @"\01?ExternAndInlineFn@@YAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
extern inline void ExternAndInlineFn() {}
|
|
|
|
|
|
|
|
// NORMAL-NOT: _Z18InlineThenExternFnv
|
2015-10-08 12:53:31 +08:00
|
|
|
// MSVCCOMPAT-LABEL: define weak_odr void @"\01?InlineThenExternFn@@YAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
inline void InlineThenExternFn() {}
|
|
|
|
extern void InlineThenExternFn();
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define void @_Z18ExternThenInlineFnv
|
|
|
|
// MSVCCOMPAT-LABEL: define void @"\01?ExternThenInlineFn@@YAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
extern void ExternThenInlineFn() {}
|
|
|
|
|
|
|
|
// NORMAL-NOT: _Z25ExternThenInlineThenDefFnv
|
2015-10-08 12:53:31 +08:00
|
|
|
// MSVCCOMPAT-LABEL: define weak_odr void @"\01?ExternThenInlineThenDefFn@@YAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
extern void ExternThenInlineThenDefFn();
|
|
|
|
inline void ExternThenInlineThenDefFn();
|
|
|
|
void ExternThenInlineThenDefFn() {}
|
|
|
|
|
|
|
|
// NORMAL-NOT: _Z25InlineThenExternThenDefFnv
|
2015-10-08 12:53:31 +08:00
|
|
|
// MSVCCOMPAT-LABEL: define weak_odr void @"\01?InlineThenExternThenDefFn@@YAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
inline void InlineThenExternThenDefFn();
|
|
|
|
extern void InlineThenExternThenDefFn();
|
|
|
|
void InlineThenExternThenDefFn() {}
|
|
|
|
|
|
|
|
// NORMAL-NOT: _Z17ExternAndConstexprFnv
|
2015-10-08 12:53:31 +08:00
|
|
|
// MSVCCOMPAT-LABEL: define weak_odr i32 @"\01?ExternAndConstexprFn@@YAHXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
extern constexpr int ExternAndConstexprFn() { return 0; }
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-NOT: _Z11ConstexprFnv
|
|
|
|
// MSVCCOMPAT-NOT: @"\01?ConstexprFn@@YAHXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
constexpr int ConstexprFn() { return 0; }
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
extern inline void ExternInlineOnPrimaryTemplate(T);
|
|
|
|
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define void @_Z29ExternInlineOnPrimaryTemplateIiEvT_
|
|
|
|
// MSVCCOMPAT-LABEL: define void @"\01??$ExternInlineOnPrimaryTemplate@H@@YAXH@Z"
|
2014-04-03 07:17:29 +08:00
|
|
|
template <>
|
|
|
|
void ExternInlineOnPrimaryTemplate(int) {}
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(T);
|
|
|
|
|
|
|
|
// NORMAL-NOT: _Z46ExternInlineOnPrimaryTemplateAndSpecializationIiEvT_
|
2015-10-08 12:53:31 +08:00
|
|
|
// MSVCCOMPAT-LABEL: define weak_odr void @"\01??$ExternInlineOnPrimaryTemplateAndSpecialization@H@@YAXH@Z"
|
2014-04-03 07:17:29 +08:00
|
|
|
template <>
|
|
|
|
extern inline void ExternInlineOnPrimaryTemplateAndSpecialization(int) {}
|
|
|
|
|
|
|
|
struct TypeWithInlineMethods {
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-NOT: _ZN21TypeWithInlineMethods9StaticFunEv
|
|
|
|
// MSVCCOMPAT-NOT: @"\01?StaticFun@TypeWithInlineMethods@@SAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
static void StaticFun() {}
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv
|
|
|
|
// MSVCCOMPAT-NOT: @"\01?NonStaticFun@TypeWithInlineMethods@@QEAAXXZ"
|
2014-04-03 07:17:29 +08:00
|
|
|
void NonStaticFun() { StaticFun(); }
|
|
|
|
};
|
2015-03-20 08:02:27 +08:00
|
|
|
|
|
|
|
namespace PR22959 {
|
|
|
|
template <typename>
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
S<int> Foo();
|
|
|
|
|
|
|
|
template <typename>
|
|
|
|
struct S {
|
|
|
|
friend S<int> Foo();
|
|
|
|
};
|
|
|
|
|
|
|
|
__attribute__((used)) inline S<int> Foo() { return S<int>(); }
|
2015-10-08 12:53:31 +08:00
|
|
|
// NORMAL-LABEL: define linkonce_odr void @_ZN7PR229593FooEv(
|
|
|
|
// MSVCCOMPAT-LABEL: define linkonce_odr i8 @"\01?Foo@PR22959@@YA?AU?$S@H@1@XZ"(
|
2015-03-20 08:02:27 +08:00
|
|
|
}
|