Fariborz Jahanian | 47609b0 | 2011-01-20 17:19:02 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s |
| 2 | |
Nico Weber | 99e05d0 | 2015-01-26 02:59:07 +0000 | [diff] [blame] | 3 | // 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 | |
Fariborz Jahanian | 47609b0 | 2011-01-20 17:19:02 +0000 | [diff] [blame] | 5 | struct Base { |
Fariborz Jahanian | 47609b0 | 2011-01-20 17:19:02 +0000 | [diff] [blame] | 6 | virtual void abc(void) const; |
| 7 | }; |
| 8 | |
| 9 | void Base::abc(void) const {} |
| 10 | |
| 11 | void FUNC(Base* p) { |
| 12 | p->Base::abc(); |
| 13 | } |
| 14 | |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 15 | // CHECK: getelementptr inbounds (void (%struct.Base*)*, void (%struct.Base*)** bitcast ([4 x i8*]* @_ZTV4Base to void (%struct.Base*)**), i64 2) |
Fariborz Jahanian | 47609b0 | 2011-01-20 17:19:02 +0000 | [diff] [blame] | 16 | // CHECK-NOT: call void @_ZNK4Base3abcEv |
Nico Weber | 99e05d0 | 2015-01-26 02:59:07 +0000 | [diff] [blame] | 17 | |
| 18 | template<class T> |
| 19 | struct Templ { |
| 20 | virtual void f() {} |
| 21 | virtual void g() {} |
| 22 | }; |
| 23 | template<class T> |
| 24 | struct SubTempl : public Templ<T> { |
| 25 | virtual void f() {} // override |
| 26 | virtual void g() {} // override |
| 27 | }; |
| 28 | |
| 29 | void f(SubTempl<int>* t) { |
| 30 | // Qualified calls go through the (qualified) vtable in apple-kext mode. |
Nico Weber | fe0053e | 2015-01-26 03:03:49 +0000 | [diff] [blame] | 31 | // Since t's this pointer points to SubTempl's vtable, the call needs |
| 32 | // to load Templ<int>'s vtable. Hence, Templ<int>::g needs to be |
| 33 | // instantiated in this TU, for it's referenced by the vtable. |
Nico Weber | 99e05d0 | 2015-01-26 02:59:07 +0000 | [diff] [blame] | 34 | // (This happens only in apple-kext mode; elsewhere virtual calls can always |
| 35 | // use the vtable pointer off this instead of having to load the vtable |
| 36 | // symbol.) |
| 37 | t->Templ::f(); |
| 38 | } |
| 39 | |
David Blaikie | bdf40a6 | 2015-03-13 18:21:46 +0000 | [diff] [blame] | 40 | // CHECK: getelementptr inbounds (void (%struct.Templ*)*, void (%struct.Templ*)** bitcast ([5 x i8*]* @_ZTV5TemplIiE to void (%struct.Templ*)**), i64 2) |
Nico Weber | 99e05d0 | 2015-01-26 02:59:07 +0000 | [diff] [blame] | 41 | // CHECK: define internal void @_ZN5TemplIiE1fEv(%struct.Templ* %this) |
| 42 | // CHECK: define internal void @_ZN5TemplIiE1gEv(%struct.Templ* %this) |