1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s 2 3// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant [7 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.Templ*)* @_ZN5TemplIiED1Ev to i8*), i8* bitcast (void (%struct.Templ*)* @_ZN5TemplIiED0Ev to i8*), i8* bitcast (void (%struct.Templ*)* @_ZN5TemplIiE1fEv to i8*), i8* bitcast (void (%struct.Templ*)* @_ZN5TemplIiE1gEv to i8*), i8* 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 @_ZN2B1D0Ev 15// CHECK: [[T1:%.*]] = load void (%struct.B1*)*, void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)*, void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2) 16// CHECK-NEXT: call void [[T1]](%struct.B1* [[T2:%.*]]) 17// CHECK-LABEL: define void @_Z6DELETEP2B1 18// CHECK: [[T3:%.*]] = load void (%struct.B1*)*, void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)*, void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2) 19// CHECK-NEXT: call void [[T3]](%struct.B1* [[T4:%.*]]) 20 21template<class T> 22struct Templ { 23 virtual ~Templ(); // Out-of-line so that the destructor doesn't cause a vtable 24 virtual void f() {} 25 virtual void g() {} 26}; 27template<class T> 28struct SubTempl : public Templ<T> { 29 virtual ~SubTempl() {} // override 30 virtual void f() {} // override 31 virtual void g() {} // override 32}; 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 needs 37 // to load Templ<int>'s vtable. Hence, Templ<int>::g needs to be 38 // instantiated in this TU, for it's referenced by the vtable. 39 // (This happens only in apple-kext mode; elsewhere virtual calls can always 40 // use the vtable pointer off this instead of having to load the vtable 41 // symbol.) 42 t->Templ::~Templ(); 43} 44 45// CHECK: getelementptr inbounds (void (%struct.Templ*)*, void (%struct.Templ*)** bitcast ([7 x i8*]* @_ZTV5TemplIiE to void (%struct.Templ*)**), i64 2) 46// CHECK: declare void @_ZN5TemplIiED0Ev(%struct.Templ*) 47// CHECK: define internal void @_ZN5TemplIiE1fEv(%struct.Templ* %this) 48// CHECK: define internal void @_ZN5TemplIiE1gEv(%struct.Templ* %this) 49