brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 31afa0c Raw
43 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s2 3// CHECK: @_ZTV5TemplIiE = internal unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI5TemplIiE, ptr @_ZN5TemplIiE1fEv, ptr @_ZN5TemplIiE1gEv, ptr null] }4 5struct Base { 6  virtual void abc(void) const; 7};8 9void Base::abc(void) const {}10 11void FUNC(Base* p) {12  p->Base::abc();13}14 15// CHECK: getelementptr inbounds (ptr, ptr @_ZTV4Base, i64 2)16// CHECK-NOT: call void @_ZNK4Base3abcEv17 18template<class T>19struct Templ {20  virtual void f() {}21  virtual void g() {}22};23template<class T>24struct SubTempl : public Templ<T> {25  virtual void f() {} // override26  virtual void g() {} // override27};28 29void f(SubTempl<int>* t) {30  // Qualified calls go through the (qualified) vtable in apple-kext mode.31  // Since t's this pointer points to SubTempl's vtable, the call needs32  // to load Templ<int>'s vtable.  Hence, Templ<int>::g needs to be33  // instantiated in this TU, for it's referenced by the vtable.34  // (This happens only in apple-kext mode; elsewhere virtual calls can always35  // use the vtable pointer off this instead of having to load the vtable36  // symbol.)37  t->Templ::f();38}39 40// CHECK: getelementptr inbounds (ptr, ptr @_ZTV5TemplIiE, i64 2)41// CHECK: define internal void @_ZN5TemplIiE1fEv(ptr {{[^,]*}} %this)42// CHECK: define internal void @_ZN5TemplIiE1gEv(ptr {{[^,]*}} %this)43