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