Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 %s -triple armv7-none-eabi -emit-llvm -o - | FileCheck %s
      2 
      3 struct A {
      4   virtual void f();
      5   virtual void f_const() const;
      6 
      7   A h();
      8 };
      9 
     10 A g();
     11 
     12 void f(A a, A *ap, A& ar) {
     13   // This should not be a virtual function call.
     14 
     15   // CHECK: call void @_ZN1A1fEv(%struct.A* %a)
     16   a.f();
     17 
     18   // CHECK: call void %
     19   ap->f();
     20 
     21   // CHECK: call void %
     22   ar.f();
     23 
     24   // CHECK: call void @_ZN1A1fEv
     25   A().f();
     26 
     27   // CHECK: call void @_ZN1A1fEv
     28   g().f();
     29 
     30   // CHECK: call void @_ZN1A1fEv
     31   a.h().f();
     32 
     33   // CHECK: call void @_ZNK1A7f_constEv
     34   a.f_const();
     35 
     36   // CHECK: call void @_ZN1A1fEv
     37   (a).f();
     38 }
     39 
     40 struct B {
     41   virtual void f();
     42   ~B();
     43 
     44   B h();
     45 };
     46 
     47 
     48 void f() {
     49   // CHECK: call void @_ZN1B1fEv
     50   B().f();
     51 
     52   // CHECK: call void @_ZN1B1fEv
     53   B().h().f();
     54 }
     55 
     56 namespace test2 {
     57   struct foo {
     58     virtual void f();
     59     virtual ~foo();
     60   };
     61 
     62   struct bar : public foo {
     63     virtual void f();
     64     virtual ~bar();
     65   };
     66 
     67   void f(bar *b) {
     68     // CHECK: call void @_ZN5test23foo1fEv
     69     // CHECK: call %"struct.test2::foo"* @_ZN5test23fooD1Ev
     70     b->foo::f();
     71     b->foo::~foo();
     72   }
     73 }
     74 
     75 namespace test3 {
     76   // Test that we don't crash in this case.
     77   struct B {
     78   };
     79   struct D : public B {
     80   };
     81   void f(D d) {
     82     // CHECK-LABEL: define void @_ZN5test31fENS_1DE
     83     d.B::~B();
     84   }
     85 }
     86 
     87 namespace test4 {
     88   struct Animal {
     89     virtual void eat();
     90   };
     91   struct Fish : Animal {
     92     virtual void eat();
     93   };
     94   struct Wrapper {
     95     Fish fish;
     96   };
     97   extern Wrapper *p;
     98   void test() {
     99     // CHECK: call void @_ZN5test44Fish3eatEv
    100     p->fish.eat();
    101   }
    102 }
    103