@@ -287,7 +287,7 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
287
287
if (auto *destructor = record->getDestructor ()) {
288
288
// Ensure virtual destructors have the body defined, even if they're
289
289
// not used directly, as they might be referenced by the emitted vtable.
290
- if (destructor->isVirtual ())
290
+ if (destructor->isVirtual () && !destructor-> isDeleted () )
291
291
ensureImplicitCXXDestructorBodyIsDefined (destructor);
292
292
}
293
293
for (auto *method : record->methods ()) {
@@ -342,12 +342,12 @@ void IRGenModule::finalizeClangCodeGen() {
342
342
343
343
void IRGenModule::ensureImplicitCXXDestructorBodyIsDefined (
344
344
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);
353
353
}
0 commit comments