@@ -287,7 +287,7 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
287287 if (auto *destructor = record->getDestructor ()) {
288288 // Ensure virtual destructors have the body defined, even if they're
289289 // not used directly, as they might be referenced by the emitted vtable.
290- if (destructor->isVirtual ())
290+ if (destructor->isVirtual () && !destructor-> isDeleted () )
291291 ensureImplicitCXXDestructorBodyIsDefined (destructor);
292292 }
293293 for (auto *method : record->methods ()) {
@@ -342,12 +342,12 @@ void IRGenModule::finalizeClangCodeGen() {
342342
343343void IRGenModule::ensureImplicitCXXDestructorBodyIsDefined (
344344 clang::CXXDestructorDecl *destructor) {
345- if (! destructor->isUserProvided () &&
346- ! destructor->doesThisDeclarationHaveABody ()) {
347- assert (!destructor-> isDeleted () &&
348- " Swift cannot handle a type with no known destructor. " );
349- // Make sure we define the destructor so we have something to call.
350- auto &sema = Context. getClangModuleLoader ()-> getClangSema ();
351- sema. DefineImplicitDestructor ( clang::SourceLocation (), destructor );
352- }
345+ if (destructor->isUserProvided () ||
346+ destructor->doesThisDeclarationHaveABody ())
347+ return ;
348+ assert (! destructor-> isDeleted () &&
349+ " Swift cannot handle a type with no known destructor. " );
350+ // Make sure we define the destructor so we have something to call.
351+ auto & sema = Context. getClangModuleLoader ()-> getClangSema ( );
352+ sema. DefineImplicitDestructor ( clang::SourceLocation (), destructor);
353353}
0 commit comments