Fix emission of vtables

It is (again) necessary to call DefineUsedVTables() to enable (at
least) the emission of implicitly defined destructors overriding
the virtual destructor in a base class, see the added test.
This commit is contained in:
Jonas Hahnfeld 2022-05-18 17:24:39 +02:00 committed by jenkins
parent ed72130ee6
commit b721467e15
2 changed files with 42 additions and 0 deletions

View File

@ -642,6 +642,8 @@ namespace cling {
Transaction* prevConsumerT = m_Consumer->getTransaction();
m_Consumer->setTransaction(T);
Transaction* nestedT = beginTransaction(T->getCompilationOpts());
// Process used vtables and generate implicit bodies.
getCI()->getSema().DefineUsedVTables();
// Pull all template instantiations in that came from the consumers.
getCI()->getSema().PerformPendingInstantiations();
#ifdef _WIN32

View File

@ -0,0 +1,40 @@
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
// RUN: cat %s | %cling -Xclang -verify 2>&1 | FileCheck %s
// Test that the interpreter properly generates implicitly defined destructors
// overriding the virtual destructor in the base class.
// expected-no-diagnostics
.rawInput
extern "C" int printf(const char*,...);
class A {
public:
virtual ~A() {
printf("A::~A()\n");
}
};
class B : public A {
public:
B() {
printf("B::B()\n");
}
};
.rawInput
// CHECK-NOT: error
// CHECK-NOT: Symbols not found
// CHECK: B::B()
A *b = new B;
// CHECK: A::~A()
delete b;