Skip to content

Commit 527d5b3

Browse files
committed
[move-only] Conditionalize TBDGen's special handling of class destructors just for classes.
Otherwise it triggers for non-class nominal move only types as well, which we do not want.
1 parent f676327 commit 527d5b3

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,16 @@ void TBDGenVisitor::visitConstructorDecl(ConstructorDecl *CD) {
999999
}
10001000

10011001
void TBDGenVisitor::visitDestructorDecl(DestructorDecl *DD) {
1002-
// Class destructors come in two forms (deallocating and non-deallocating),
1003-
// like constructors above. This is the deallocating one:
1002+
// Destructors come in two forms (deallocating and non-deallocating), like
1003+
// constructors above. Classes use both but move only non-class nominal types
1004+
// only use the deallocating one. This is the deallocating one:
10041005
visitAbstractFunctionDecl(DD);
10051006

1006-
auto parentClass = DD->getParent()->getSelfClassDecl();
1007-
1008-
// But the non-deallocating one doesn't apply to some @objc classes.
1009-
if (!Lowering::usesObjCAllocator(parentClass)) {
1010-
addSymbol(SILDeclRef(DD, SILDeclRef::Kind::Destroyer));
1007+
if (auto parentClass = DD->getParent()->getSelfClassDecl()) {
1008+
// But the non-deallocating one doesn't apply to some @objc classes.
1009+
if (!Lowering::usesObjCAllocator(parentClass)) {
1010+
addSymbol(SILDeclRef(DD, SILDeclRef::Kind::Destroyer));
1011+
}
10111012
}
10121013
}
10131014

0 commit comments

Comments
 (0)