From c16668acc904bec0ee20f6bfc2a72d6a3821a589 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 27 Nov 2009 01:42:12 +0000 Subject: [PATCH] Fix for PR5594: use EmitGlobalDefinition instead of EmitCXXDestructor so that we check whether the vtable needs to be generated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89984 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCXX.cpp | 6 +++--- test/CodeGenCXX/virt-dtor-key.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 test/CodeGenCXX/virt-dtor-key.cpp diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index a51845a52b..a848b1269b 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -793,9 +793,9 @@ const char *CodeGenModule::getMangledCXXCtorName(const CXXConstructorDecl *D, void CodeGenModule::EmitCXXDestructors(const CXXDestructorDecl *D) { if (D->isVirtual()) - EmitCXXDestructor(D, Dtor_Deleting); - EmitCXXDestructor(D, Dtor_Complete); - EmitCXXDestructor(D, Dtor_Base); + EmitGlobalDefinition(GlobalDecl(D, Dtor_Deleting)); + EmitGlobalDefinition(GlobalDecl(D, Dtor_Complete)); + EmitGlobalDefinition(GlobalDecl(D, Dtor_Base)); } void CodeGenModule::EmitCXXDestructor(const CXXDestructorDecl *D, diff --git a/test/CodeGenCXX/virt-dtor-key.cpp b/test/CodeGenCXX/virt-dtor-key.cpp new file mode 100644 index 0000000000..30f3563d8a --- /dev/null +++ b/test/CodeGenCXX/virt-dtor-key.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s +// CHECK: @_ZTI3foo = linkonce_odr constant +class foo { + foo(); + virtual ~foo(); +}; + +foo::~foo() { +} -- 2.40.0