Home | History | Annotate | Download | only in CodeGenCXX
      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
      3 // CHECK: ; ModuleID
      4 
      5 struct A {
      6     inline void f();
      7 };
      8 
      9 // CHECK-NOT: define void @_ZN1A1fEv
     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 
     23 // CHECK-LABEL: define void @_Z1fv
     24 void f() { }
     25 
     26 // <rdar://problem/8740363>
     27 inline void f1(int);
     28 
     29 // CHECK-LABEL: define linkonce_odr void @_Z2f1i
     30 void f1(int) { }
     31 
     32 void test_f1() { f1(17); }
     33 
     34 // PR8789
     35 namespace test1 {
     36   template <typename T> class ClassTemplate {
     37   private:
     38     friend void T::func();
     39     void g() {}
     40   };
     41 
     42   // CHECK-LABEL: define linkonce_odr void @_ZN5test11C4funcEv(
     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 }
     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   }
     69   // CHECK-LABEL: define linkonce_odr void @_ZN5test21fERKNS_1AE
     70 }
     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 };
    124