@@ -239,8 +239,7 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
239
239
for (auto conformance :
240
240
IDC->getLocalConformances (ConformanceLookupKind::NonInherited)) {
241
241
auto protocol = conformance->getProtocol ();
242
- if (Ctx.getOpts ().PublicSymbolsOnly &&
243
- getDeclLinkage (protocol) != FormalLinkage::PublicUnique)
242
+ if (canSkipNominal (protocol))
244
243
continue ;
245
244
246
245
auto needsWTable =
@@ -308,8 +307,7 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
308
307
}
309
308
310
309
bool addClassMetadata (ClassDecl *CD) {
311
- if (Ctx.getOpts ().PublicSymbolsOnly &&
312
- getDeclLinkage (CD) != FormalLinkage::PublicUnique)
310
+ if (canSkipNominal (CD))
313
311
return false ;
314
312
315
313
auto &ctxt = CD->getASTContext ();
@@ -365,6 +363,18 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
365
363
Visitor.addMethodDescriptor (method);
366
364
}
367
365
366
+ // / Returns `true` if the neither the nominal nor its members have any symbols
367
+ // / that need to be visited because it has non-public linkage.
368
+ bool canSkipNominal (const NominalTypeDecl *NTD) {
369
+ if (!Ctx.getOpts ().PublicSymbolsOnly )
370
+ return false ;
371
+
372
+ if (NTD->hasClangNode ())
373
+ return false ;
374
+
375
+ return getDeclLinkage (NTD) != FormalLinkage::PublicUnique;
376
+ }
377
+
368
378
public:
369
379
SILSymbolVisitorImpl (SILSymbolVisitor &Visitor,
370
380
const SILSymbolVisitorContext &Ctx)
@@ -585,6 +595,9 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
585
595
}
586
596
587
597
void visitNominalTypeDecl (NominalTypeDecl *NTD) {
598
+ if (canSkipNominal (NTD))
599
+ return ;
600
+
588
601
auto declaredType = NTD->getDeclaredType ()->getCanonicalType ();
589
602
590
603
if (!NTD->getObjCImplementationDecl ()) {
@@ -680,12 +693,16 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
680
693
}
681
694
682
695
void visitExtensionDecl (ExtensionDecl *ED) {
696
+ auto nominal = ED->getExtendedNominal ();
697
+ if (canSkipNominal (nominal))
698
+ return ;
699
+
683
700
if (auto CD = dyn_cast_or_null<ClassDecl>(ED->getImplementedObjCDecl ())) {
684
701
// @_objcImplementation extensions generate the class metadata symbols.
685
702
(void )addClassMetadata (CD);
686
703
}
687
704
688
- if (!isa<ProtocolDecl>(ED-> getExtendedNominal () )) {
705
+ if (!isa<ProtocolDecl>(nominal )) {
689
706
addConformances (ED);
690
707
}
691
708
@@ -738,6 +755,9 @@ class SILSymbolVisitorImpl : public ASTVisitor<SILSymbolVisitorImpl> {
738
755
#endif
739
756
740
757
void visitProtocolDecl (ProtocolDecl *PD) {
758
+ if (canSkipNominal (PD))
759
+ return ;
760
+
741
761
if (!PD->isObjC () && !PD->isMarkerProtocol ()) {
742
762
Visitor.addProtocolDescriptor (PD);
743
763
0 commit comments