@@ -741,11 +741,16 @@ static void printDifferentiableAttrArguments(
741741
742742// / Returns the `PlatformKind` referenced by \p attr if applicable, or
743743// / `std::nullopt` otherwise.
744- static std::optional<PlatformKind>
745- referencedPlatform ( const DeclAttribute *attr ) {
744+ static std::optional<PlatformKind> referencedPlatform ( const DeclAttribute *attr,
745+ const Decl *D ) {
746746 switch (attr->getKind ()) {
747747 case DeclAttrKind::Available:
748- return static_cast <const AvailableAttr *>(attr)->getPlatform ();
748+ if (auto semanticAttr = D->getSemanticAvailableAttr (
749+ static_cast <const AvailableAttr *>(attr))) {
750+ if (semanticAttr->isPlatformSpecific ())
751+ return semanticAttr->getPlatform ();
752+ }
753+ return std::nullopt ;
749754 case DeclAttrKind::BackDeployed:
750755 return static_cast <const BackDeployedAttr *>(attr)->Platform ;
751756 case DeclAttrKind::OriginallyDefinedIn:
@@ -757,8 +762,8 @@ referencedPlatform(const DeclAttribute *attr) {
757762
758763// / Returns true if \p attr contains a reference to a `PlatformKind` that should
759764// / be considered SPI.
760- static bool referencesSPIPlatform (const DeclAttribute *attr) {
761- if (auto platform = referencedPlatform (attr))
765+ static bool referencesSPIPlatform (const DeclAttribute *attr, const Decl *D ) {
766+ if (auto platform = referencedPlatform (attr, D ))
762767 return isPlatformSPI (*platform);
763768 return false ;
764769}
@@ -805,7 +810,7 @@ void DeclAttributes::print(ASTPrinter &Printer, const PrintOptions &Options,
805810 // In the public interfaces of -library-level=api modules, skip attributes
806811 // that reference SPI platforms.
807812 if (Options.printPublicInterface () && libraryLevelAPI &&
808- referencesSPIPlatform (DA))
813+ referencesSPIPlatform (DA, D ))
809814 continue ;
810815
811816 // If we're supposed to suppress expanded macros, check whether this is
0 commit comments