@@ -741,11 +741,16 @@ static void printDifferentiableAttrArguments(
741
741
742
742
// / Returns the `PlatformKind` referenced by \p attr if applicable, or
743
743
// / `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 ) {
746
746
switch (attr->getKind ()) {
747
747
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;
749
754
case DeclAttrKind::BackDeployed:
750
755
return static_cast <const BackDeployedAttr *>(attr)->Platform ;
751
756
case DeclAttrKind::OriginallyDefinedIn:
@@ -757,8 +762,8 @@ referencedPlatform(const DeclAttribute *attr) {
757
762
758
763
// / Returns true if \p attr contains a reference to a `PlatformKind` that should
759
764
// / 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 ))
762
767
return isPlatformSPI (*platform);
763
768
return false ;
764
769
}
@@ -805,7 +810,7 @@ void DeclAttributes::print(ASTPrinter &Printer, const PrintOptions &Options,
805
810
// In the public interfaces of -library-level=api modules, skip attributes
806
811
// that reference SPI platforms.
807
812
if (Options.printPublicInterface () && libraryLevelAPI &&
808
- referencesSPIPlatform (DA))
813
+ referencesSPIPlatform (DA, D ))
809
814
continue ;
810
815
811
816
// If we're supposed to suppress expanded macros, check whether this is
0 commit comments