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