@@ -566,71 +566,74 @@ SymbolGraph::serializeDeclarationFragments(StringRef Key, Type T,
566
566
T->print (Printer, getDeclarationFragmentsPrintOptions ());
567
567
}
568
568
569
- bool SymbolGraph::isImplicitlyPrivate (const ValueDecl *VD ,
569
+ bool SymbolGraph::isImplicitlyPrivate (const Decl *D ,
570
570
bool IgnoreContext) const {
571
571
// Don't record unconditionally private declarations
572
- if (VD ->isPrivateStdlibDecl (/* treatNonBuiltinProtocolsAsPublic=*/ false )) {
572
+ if (D ->isPrivateStdlibDecl (/* treatNonBuiltinProtocolsAsPublic=*/ false )) {
573
573
return true ;
574
574
}
575
575
576
576
// Don't record effectively internal declarations if specified
577
577
if (Walker.Options .MinimumAccessLevel > AccessLevel::Internal &&
578
- VD ->hasUnderscoredNaming ()) {
578
+ D ->hasUnderscoredNaming ()) {
579
579
return true ;
580
580
}
581
581
582
- // Don't include declarations with the @_spi attribute for now.
583
- if (VD->getAttrs ().getAttribute (DeclAttrKind::DAK_SPIAccessControl)) {
584
- return true ;
582
+ // Don't include declarations with the @_spi attribute unless the
583
+ // access control filter is internal or below.
584
+ if (D->isSPI ()) {
585
+ return Walker.Options .MinimumAccessLevel > AccessLevel::Internal;
585
586
}
586
587
587
- // Symbols must meet the minimum access level to be included in the graph.
588
- if (VD->getFormalAccess () < Walker.Options .MinimumAccessLevel ) {
589
- return true ;
588
+ if (const auto *Extension = dyn_cast<ExtensionDecl>(D)) {
589
+ if (const auto *Nominal = Extension->getExtendedNominal ()) {
590
+ return isImplicitlyPrivate (Nominal, IgnoreContext);
591
+ }
590
592
}
591
593
592
- // Special cases below.
594
+ if (const auto *VD = dyn_cast<ValueDecl>(D)) {
595
+ // Symbols must meet the minimum access level to be included in the graph.
596
+ if (VD->getFormalAccess () < Walker.Options .MinimumAccessLevel ) {
597
+ return true ;
598
+ }
593
599
594
- auto BaseName = VD-> getBaseName (). userFacingName ();
600
+ // Special cases below.
595
601
596
- // ${MODULE}Version{Number,String} in ${Module}.h
597
- SmallString<32 > VersionNameIdentPrefix { M.getName ().str () };
598
- VersionNameIdentPrefix.append (" Version" );
599
- if (BaseName.startswith (VersionNameIdentPrefix.str ())) {
600
- return true ;
601
- }
602
+ auto BaseName = VD->getBaseName ().userFacingName ();
602
603
603
- // Automatically mapped SIMD types
604
- auto IsGlobalSIMDType = llvm::StringSwitch<bool >(BaseName)
605
- #define MAP_SIMD_TYPE (C_TYPE, _, __ ) \
606
- .Case (" swift_" #C_TYPE " 2" , true ) \
607
- .Case (" swift_" #C_TYPE " 3" , true ) \
608
- .Case (" swift_" #C_TYPE " 4" , true )
609
- #include " swift/ClangImporter/SIMDMappedTypes.def"
610
- .Case (" SWIFT_TYPEDEFS" , true )
611
- .Case (" char16_t" , true )
612
- .Case (" char32_t" , true )
613
- .Default (false );
614
-
615
- if (IsGlobalSIMDType) {
616
- return true ;
617
- }
604
+ // ${MODULE}Version{Number,String} in ${Module}.h
605
+ SmallString<32 > VersionNameIdentPrefix { M.getName ().str () };
606
+ VersionNameIdentPrefix.append (" Version" );
607
+ if (BaseName.startswith (VersionNameIdentPrefix.str ())) {
608
+ return true ;
609
+ }
618
610
619
- if (IgnoreContext) {
620
- return false ;
611
+ // Automatically mapped SIMD types
612
+ auto IsGlobalSIMDType = llvm::StringSwitch<bool >(BaseName)
613
+ #define MAP_SIMD_TYPE (C_TYPE, _, __ ) \
614
+ .Case (" swift_" #C_TYPE " 2" , true ) \
615
+ .Case (" swift_" #C_TYPE " 3" , true ) \
616
+ .Case (" swift_" #C_TYPE " 4" , true )
617
+ #include " swift/ClangImporter/SIMDMappedTypes.def"
618
+ .Case (" SWIFT_TYPEDEFS" , true )
619
+ .Case (" char16_t" , true )
620
+ .Case (" char32_t" , true )
621
+ .Default (false );
622
+
623
+ if (IsGlobalSIMDType) {
624
+ return true ;
625
+ }
626
+
627
+ if (IgnoreContext) {
628
+ return false ;
629
+ }
621
630
}
622
631
623
632
// Check up the parent chain. Anything inside a privately named
624
633
// thing is also private. We could be looking at the `B` of `_A.B`.
625
- if (const auto *DC = VD ->getDeclContext ()) {
634
+ if (const auto *DC = D ->getDeclContext ()) {
626
635
if (const auto *Parent = DC->getAsDecl ()) {
627
- if (const auto *ParentVD = dyn_cast<ValueDecl>(Parent)) {
628
- return isImplicitlyPrivate (ParentVD, IgnoreContext);
629
- } else if (const auto *Extension = dyn_cast<ExtensionDecl>(Parent)) {
630
- if (const auto *Nominal = Extension->getExtendedNominal ()) {
631
- return isImplicitlyPrivate (Nominal, IgnoreContext);
632
- }
633
- }
636
+ return isImplicitlyPrivate (Parent, IgnoreContext);
634
637
}
635
638
}
636
639
return false ;
0 commit comments