Skip to content

Commit 359565a

Browse files
committed
fix
1 parent cd1ca50 commit 359565a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/IRGen/GenClangDecl.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

343343
void 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
}

test/Interop/Cxx/class/virtual-destructor-vtable-ref-irgen.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public func test() {
103103
}
104104

105105
// Make sure we reach the virtual destructor of 'Func'.
106-
// CHECK: define linkonce_odr {{.*}} @{{_ZN4impl4FuncIZNK8MyFutureIiE12OnCompletionEPFvPvES3_EUlRK12MyFutureBaseE_FvS8_EED2Ev|\?\?1\?\$BaseClass@\$\$A6AXAEBVMyFutureBase@@@Z@impl@@UEAA@XZ}}
106+
// CHECK: define linkonce_odr {{.*}} @{{_ZN4impl4FuncIZNK8MyFutureIiE12OnCompletionEPFvPvES3_EUlRK12MyFutureBaseE_FvS8_EED2Ev|"\?\?1\?\$BaseClass@\$\$A6AXAEBVMyFutureBase@@@Z@impl@@UEAA@XZ"}}

0 commit comments

Comments
 (0)