@@ -697,56 +697,6 @@ bool ParameterList::hasInternalParameter(StringRef Prefix) const {
697697  return  false ;
698698}
699699
700- bool  Decl::hasUnderscoredNaming () const  {
701-   const  Decl *D = this ;
702-   if  (const  auto  AFD = dyn_cast<AbstractFunctionDecl>(D)) {
703-     //  If it's a function with a parameter with leading underscore, it's a
704-     //  private function.
705-     if  (AFD->getParameters ()->hasInternalParameter (" _"  )) {
706-       return  true ;
707-     }
708-   }
709- 
710-   if  (const  auto  SubscriptD = dyn_cast<SubscriptDecl>(D)) {
711-     if  (SubscriptD->getIndices ()->hasInternalParameter (" _"  )) {
712-       return  true ;
713-     }
714-   }
715- 
716-   if  (const  auto  PD = dyn_cast<ProtocolDecl>(D)) {
717-     if  (PD->getAttrs ().hasAttribute <ShowInInterfaceAttr>()) {
718-       return  false ;
719-     }
720-     StringRef NameStr = PD->getNameStr ();
721-     if  (NameStr.startswith (" _Builtin"  )) {
722-       return  true ;
723-     }
724-     if  (NameStr.startswith (" _ExpressibleBy"  )) {
725-       return  true ;
726-     }
727-   }
728- 
729-   if  (const  auto  ImportD = dyn_cast<ImportDecl>(D)) {
730-     if  (const  auto  *Mod = ImportD->getModule ()) {
731-       if  (Mod->isSwiftShimsModule ()) {
732-         return  true ;
733-       }
734-     }
735-   }
736- 
737-   const  auto  VD = dyn_cast<ValueDecl>(D);
738-   if  (!VD || !VD->hasName ()) {
739-     return  false ;
740-   }
741- 
742-   if  (!VD->getBaseName ().isSpecial () &&
743-       VD->getBaseName ().getIdentifier ().str ().startswith (" _"  )) {
744-     return  true ;
745-   }
746- 
747-   return  false ;
748- }
749- 
750700bool  Decl::isPrivateStdlibDecl (bool  treatNonBuiltinProtocolsAsPublic) const  {
751701  const  Decl *D = this ;
752702  if  (auto  ExtD = dyn_cast<ExtensionDecl>(D)) {
@@ -768,12 +718,47 @@ bool Decl::isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic) const {
768718      FU->getKind () != FileUnitKind::SerializedAST)
769719    return  false ;
770720
721+   if  (auto  AFD = dyn_cast<AbstractFunctionDecl>(D)) {
722+     //  If it's a function with a parameter with leading underscore, it's a
723+     //  private function.
724+     if  (AFD->getParameters ()->hasInternalParameter (" _"  ))
725+       return  true ;
726+   }
727+ 
728+   if  (auto  SubscriptD = dyn_cast<SubscriptDecl>(D)) {
729+     if  (SubscriptD->getIndices ()->hasInternalParameter (" _"  ))
730+       return  true ;
731+   }
732+ 
771733  if  (auto  PD = dyn_cast<ProtocolDecl>(D)) {
734+     if  (PD->getAttrs ().hasAttribute <ShowInInterfaceAttr>())
735+       return  false ;
736+     StringRef NameStr = PD->getNameStr ();
737+     if  (NameStr.startswith (" _Builtin"  ))
738+       return  true ;
739+     if  (NameStr.startswith (" _ExpressibleBy"  ))
740+       return  true ;
772741    if  (treatNonBuiltinProtocolsAsPublic)
773742      return  false ;
774743  }
775744
776-   return  hasUnderscoredNaming ();
745+   if  (auto  ImportD = dyn_cast<ImportDecl>(D)) {
746+     if  (auto  *Mod = ImportD->getModule ()) {
747+       if  (Mod->isSwiftShimsModule ())
748+         return  true ;
749+     }
750+   }
751+ 
752+   auto  VD = dyn_cast<ValueDecl>(D);
753+   if  (!VD || !VD->hasName ())
754+     return  false ;
755+ 
756+   //  If the name has leading underscore then it's a private symbol.
757+   if  (!VD->getBaseName ().isSpecial () &&
758+       VD->getBaseName ().getIdentifier ().str ().startswith (" _"  ))
759+     return  true ;
760+ 
761+   return  false ;
777762}
778763
779764AvailabilityContext Decl::getAvailabilityForLinkage () const  {
0 commit comments