@@ -110,6 +110,8 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
110
110
111
111
void visitClassDecl (ClassDecl *CD);
112
112
113
+ void visitConstructorDecl (ConstructorDecl *CD);
114
+
113
115
void visitExtensionDecl (ExtensionDecl *ED);
114
116
115
117
void visitProtocolDecl (ProtocolDecl *PD);
@@ -369,10 +371,8 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
369
371
addSymbol (LinkEntity::forFieldOffset (var, /* isIndirect=*/ true ));
370
372
}
371
373
372
- // The non-allocating forms of the constructors and destructors.
373
- if (auto ctor = dyn_cast<ConstructorDecl>(value)) {
374
- addSymbol (SILDeclRef (ctor, SILDeclRef::Kind::Initializer));
375
- } else if (auto dtor = dyn_cast<DestructorDecl>(value)) {
374
+ // The non-allocating forms of the destructors.
375
+ if (auto dtor = dyn_cast<DestructorDecl>(value)) {
376
376
// ObjC classes don't have a symbol for their destructor.
377
377
if (!isObjC)
378
378
addSymbol (SILDeclRef (dtor, SILDeclRef::Kind::Destroyer));
@@ -382,6 +382,16 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
382
382
visitNominalTypeDecl (CD);
383
383
}
384
384
385
+ void TBDGenVisitor::visitConstructorDecl (ConstructorDecl *CD) {
386
+ if (CD->getParent ()->getAsClassOrClassExtensionContext ()) {
387
+ // Class constructors come in two forms, allocating and non-allocating. The
388
+ // default ValueDecl handling gives the allocating one, so we have to
389
+ // manually include the non-allocating one.
390
+ addSymbol (SILDeclRef (CD, SILDeclRef::Kind::Initializer));
391
+ }
392
+ visitAbstractFunctionDecl (CD);
393
+ }
394
+
385
395
void TBDGenVisitor::visitExtensionDecl (ExtensionDecl *ED) {
386
396
if (!ED->getExtendedType ()->isExistentialType ()) {
387
397
addConformances (ED);
0 commit comments