[cxx-interop] Always instantiate the default destructor

This fixes a linker error when using `std::function` from Swift.

rdar://103979602
This commit is contained in:
Egor Zhdan
2024-02-05 19:52:20 +00:00
parent 876c056153
commit f56fa41ac6

View File

@@ -263,6 +263,10 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
// Unfortunately, implicitly defined CXXDestructorDecls don't have a real
// body, so we need to traverse these manually.
if (auto *dtor = dyn_cast<clang::CXXDestructorDecl>(next)) {
if (dtor->isImplicit() && dtor->isDefaulted() && !dtor->isDeleted() &&
!dtor->doesThisDeclarationHaveABody())
clangSema.DefineImplicitDestructor(dtor->getLocation(), dtor);
if (dtor->isImplicit() || dtor->hasBody()) {
auto cxxRecord = dtor->getParent();