49 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -disable-O0-optnone -emit-llvm -o - %s | FileCheck %s2 3// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant { [7 x ptr] } { [7 x ptr] [ptr null, ptr null, ptr @_ZN5TemplIiED1Ev, ptr @_ZN5TemplIiED0Ev, ptr @_ZN5TemplIiE1fEv, ptr @_ZN5TemplIiE1gEv, ptr null] }4 5struct B1 { 6 virtual ~B1(); 7};8 9B1::~B1() {}10 11void DELETE(B1 *pb1) {12 pb1->B1::~B1();13}14// CHECK-LABEL: define{{.*}} void @_ZN2B1D0Ev15// CHECK: [[T1:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2)16// CHECK-NEXT: call void [[T1]](ptr {{[^,]*}} [[T2:%.*]])17// CHECK-LABEL: define{{.*}} void @_Z6DELETEP2B118// CHECK: [[T3:%.*]] = load ptr, ptr getelementptr inbounds (ptr, ptr @_ZTV2B1, i64 2)19// CHECK-NEXT: call void [[T3]](ptr {{[^,]*}} [[T4:%.*]])20 21template<class T>22struct Templ {23 virtual ~Templ(); // Out-of-line so that the destructor doesn't cause a vtable24 virtual void f() {}25 virtual void g() {}26};27template<class T>28struct SubTempl : public Templ<T> {29 virtual ~SubTempl() {} // override30 virtual void f() {} // override31 virtual void g() {} // override32};33 34void f(SubTempl<int>* t) {35 // Qualified calls go through the (qualified) vtable in apple-kext mode.36 // Since t's this pointer points to SubTempl's vtable, the call needs37 // to load Templ<int>'s vtable. Hence, Templ<int>::g needs to be38 // instantiated in this TU, for it's referenced by the vtable.39 // (This happens only in apple-kext mode; elsewhere virtual calls can always40 // use the vtable pointer off this instead of having to load the vtable41 // symbol.)42 t->Templ::~Templ();43}44 45// CHECK: getelementptr inbounds (ptr, ptr @_ZTV5TemplIiE, i64 2)46// CHECK: declare void @_ZN5TemplIiED0Ev(ptr {{[^,]*}})47// CHECK: define internal void @_ZN5TemplIiE1fEv(ptr {{[^,]*}} %this)48// CHECK: define internal void @_ZN5TemplIiE1gEv(ptr {{[^,]*}} %this)49