From 416ada0f75bab22b084a1776deb229cd4a669c4d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 1 Jun 2017 20:58:49 +0000 Subject: Vendor import of clang trunk r304460: https://llvm.org/svn/llvm-project/cfe/trunk@304460 --- test/CodeGenCXX/vtable-available-externally.cpp | 32 +++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'test/CodeGenCXX/vtable-available-externally.cpp') diff --git a/test/CodeGenCXX/vtable-available-externally.cpp b/test/CodeGenCXX/vtable-available-externally.cpp index ae81959a75e9..db99f73d9e72 100644 --- a/test/CodeGenCXX/vtable-available-externally.cpp +++ b/test/CodeGenCXX/vtable-available-externally.cpp @@ -12,6 +12,7 @@ // RUN: FileCheck --check-prefix=CHECK-TEST14 %s < %t.opt // RUN: FileCheck --check-prefix=CHECK-TEST15 %s < %t.opt // RUN: FileCheck --check-prefix=CHECK-TEST16 %s < %t.opt +// RUN: FileCheck --check-prefix=CHECK-TEST17 %s < %t.opt #include @@ -274,8 +275,8 @@ struct C { virtual D& operator=(const D&); }; -// Cannot emit B's vtable available_externally, because we cannot create -// a reference to the inline virtual B::operator= function. +// Cannot emit D's vtable available_externally, because we cannot create +// a reference to the inline virtual D::operator= function. // CHECK-TEST11: @_ZTVN6Test111DE = external unnamed_addr constant struct D : C { virtual void key(); @@ -391,3 +392,30 @@ void test() { } } +namespace Test17 { +// This test checks if we emit vtables opportunistically. +// CHECK-TEST17-DAG: @_ZTVN6Test171AE = available_externally +// CHECK-TEST17-DAG: @_ZTVN6Test171BE = external + +struct A { + virtual void key(); + virtual void bar() {} +}; + +// We won't gonna use deleting destructor for this type, which will disallow +// emitting vtable as available_externally +struct B { + virtual void key(); + virtual ~B() {} +}; + +void testcaseA() { + A a; + a.bar(); // this forces to emit definition of bar +} + +void testcaseB() { + B b; // This only forces emitting of complete object destructor +} + +} // namespace Test17 -- cgit v1.3