summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/apple-kext-indirect-call.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2015-05-27 18:47:56 +0000
committerdim <dim@FreeBSD.org>2015-05-27 18:47:56 +0000
commit3191b2b32a96e1a6ee833fcca73e5c8e0c67ba65 (patch)
treedbbd4047878da71c1a706e26ce05b4e7791b14cc /test/CodeGenCXX/apple-kext-indirect-call.cpp
parent38d6f2e7f2ce51a5b3836d26596c6c34a3288752 (diff)
downloadFreeBSD-src-3191b2b32a96e1a6ee833fcca73e5c8e0c67ba65.zip
FreeBSD-src-3191b2b32a96e1a6ee833fcca73e5c8e0c67ba65.tar.gz
Vendor import of clang trunk r238337:
https://llvm.org/svn/llvm-project/cfe/trunk@238337
Diffstat (limited to 'test/CodeGenCXX/apple-kext-indirect-call.cpp')
-rw-r--r--test/CodeGenCXX/apple-kext-indirect-call.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/CodeGenCXX/apple-kext-indirect-call.cpp b/test/CodeGenCXX/apple-kext-indirect-call.cpp
new file mode 100644
index 0000000..e4c03b5
--- /dev/null
+++ b/test/CodeGenCXX/apple-kext-indirect-call.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -emit-llvm -o - %s | FileCheck %s
+
+// 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]
+
+struct Base {
+ virtual void abc(void) const;
+};
+
+void Base::abc(void) const {}
+
+void FUNC(Base* p) {
+ p->Base::abc();
+}
+
+// CHECK: getelementptr inbounds (void (%struct.Base*)*, void (%struct.Base*)** bitcast ([4 x i8*]* @_ZTV4Base to void (%struct.Base*)**), i64 2)
+// CHECK-NOT: call void @_ZNK4Base3abcEv
+
+template<class T>
+struct Templ {
+ virtual void f() {}
+ virtual void g() {}
+};
+template<class T>
+struct SubTempl : public Templ<T> {
+ virtual void f() {} // override
+ virtual void g() {} // override
+};
+
+void f(SubTempl<int>* t) {
+ // Qualified calls go through the (qualified) vtable in apple-kext mode.
+ // Since t's this pointer points to SubTempl's vtable, the call needs
+ // to load Templ<int>'s vtable. Hence, Templ<int>::g needs to be
+ // instantiated in this TU, for it's referenced by the vtable.
+ // (This happens only in apple-kext mode; elsewhere virtual calls can always
+ // use the vtable pointer off this instead of having to load the vtable
+ // symbol.)
+ t->Templ::f();
+}
+
+// CHECK: getelementptr inbounds (void (%struct.Templ*)*, void (%struct.Templ*)** bitcast ([5 x i8*]* @_ZTV5TemplIiE to void (%struct.Templ*)**), i64 2)
+// CHECK: define internal void @_ZN5TemplIiE1fEv(%struct.Templ* %this)
+// CHECK: define internal void @_ZN5TemplIiE1gEv(%struct.Templ* %this)
OpenPOWER on IntegriCloud