1*67e74705SXin Li // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s
2*67e74705SXin Li
3*67e74705SXin Li // CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant [5 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI5TemplIiE to i8*), i8* bitcast (void (%struct.Templ*)* @_ZN5TemplIiE1fEv to i8*), i8* bitcast (void (%struct.Templ*)* @_ZN5TemplIiE1gEv to i8*), i8* null]
4*67e74705SXin Li
5*67e74705SXin Li struct Base {
6*67e74705SXin Li virtual void abc(void) const;
7*67e74705SXin Li };
8*67e74705SXin Li
abc(void) const9*67e74705SXin Li void Base::abc(void) const {}
10*67e74705SXin Li
FUNC(Base * p)11*67e74705SXin Li void FUNC(Base* p) {
12*67e74705SXin Li p->Base::abc();
13*67e74705SXin Li }
14*67e74705SXin Li
15*67e74705SXin Li // CHECK: getelementptr inbounds (void (%struct.Base*)*, void (%struct.Base*)** bitcast ([4 x i8*]* @_ZTV4Base to void (%struct.Base*)**), i64 2)
16*67e74705SXin Li // CHECK-NOT: call void @_ZNK4Base3abcEv
17*67e74705SXin Li
18*67e74705SXin Li template<class T>
19*67e74705SXin Li struct Templ {
fTempl20*67e74705SXin Li virtual void f() {}
gTempl21*67e74705SXin Li virtual void g() {}
22*67e74705SXin Li };
23*67e74705SXin Li template<class T>
24*67e74705SXin Li struct SubTempl : public Templ<T> {
fSubTempl25*67e74705SXin Li virtual void f() {} // override
gSubTempl26*67e74705SXin Li virtual void g() {} // override
27*67e74705SXin Li };
28*67e74705SXin Li
f(SubTempl<int> * t)29*67e74705SXin Li void f(SubTempl<int>* t) {
30*67e74705SXin Li // Qualified calls go through the (qualified) vtable in apple-kext mode.
31*67e74705SXin Li // Since t's this pointer points to SubTempl's vtable, the call needs
32*67e74705SXin Li // to load Templ<int>'s vtable. Hence, Templ<int>::g needs to be
33*67e74705SXin Li // instantiated in this TU, for it's referenced by the vtable.
34*67e74705SXin Li // (This happens only in apple-kext mode; elsewhere virtual calls can always
35*67e74705SXin Li // use the vtable pointer off this instead of having to load the vtable
36*67e74705SXin Li // symbol.)
37*67e74705SXin Li t->Templ::f();
38*67e74705SXin Li }
39*67e74705SXin Li
40*67e74705SXin Li // CHECK: getelementptr inbounds (void (%struct.Templ*)*, void (%struct.Templ*)** bitcast ([5 x i8*]* @_ZTV5TemplIiE to void (%struct.Templ*)**), i64 2)
41*67e74705SXin Li // CHECK: define internal void @_ZN5TemplIiE1fEv(%struct.Templ* %this)
42*67e74705SXin Li // CHECK: define internal void @_ZN5TemplIiE1gEv(%struct.Templ* %this)
43