@@ -190,7 +190,7 @@ DeclAttributes::findMostSpecificActivePlatform(const ASTContext &ctx) const{
190190 continue ;
191191
192192 // We have an attribute that is active for the platform, but
193- // is it more specific than our curent best?
193+ // is it more specific than our current best?
194194 if (!bestAttr || inheritsAvailabilityFromPlatform (avAttr->Platform ,
195195 bestAttr->Platform )) {
196196 bestAttr = avAttr;
@@ -356,6 +356,48 @@ DeclAttributes::getSoftDeprecated(const ASTContext &ctx) const {
356356 return conditional;
357357}
358358
359+ const AvailableAttr *DeclAttributes::getNoAsync (const ASTContext &ctx) const {
360+ const AvailableAttr *bestAttr = nullptr ;
361+ for (const DeclAttribute *attr : *this ) {
362+ if (const AvailableAttr *avAttr = dyn_cast<AvailableAttr>(attr)) {
363+ if (avAttr->isInvalid ())
364+ continue ;
365+
366+ if (avAttr->getPlatformAgnosticAvailability () ==
367+ PlatformAgnosticAvailabilityKind::NoAsync) {
368+ // An API may only be unavailable on specific platforms.
369+ // If it doesn't have a platform associated with it, then it's
370+ // unavailable for all platforms, so we should include it. If it does
371+ // have a platform and we are not that platform, then it doesn't apply
372+ // to us.
373+ const bool isGoodForPlatform =
374+ (avAttr->hasPlatform () && avAttr->isActivePlatform (ctx)) ||
375+ !avAttr->hasPlatform ();
376+
377+ if (!isGoodForPlatform)
378+ continue ;
379+
380+ if (!bestAttr) {
381+ // If there is no best attr selected
382+ // and the attr either has an active platform, or doesn't have one at
383+ // all, select it.
384+ bestAttr = avAttr;
385+ } else if (bestAttr && avAttr->hasPlatform () &&
386+ bestAttr->hasPlatform () &&
387+ inheritsAvailabilityFromPlatform (avAttr->Platform ,
388+ bestAttr->Platform )) {
389+ // if they both have a viable platform, use the better one
390+ bestAttr = avAttr;
391+ } else if (avAttr->hasPlatform () && !bestAttr->hasPlatform ()) {
392+ // Use the one more specific
393+ bestAttr = avAttr;
394+ }
395+ }
396+ }
397+ }
398+ return bestAttr;
399+ }
400+
359401void DeclAttributes::dump (const Decl *D) const {
360402 StreamPrinter P (llvm::errs ());
361403 PrintOptions PO = PrintOptions::printDeclarations ();
@@ -394,6 +436,7 @@ static bool isShortAvailable(const DeclAttribute *DA) {
394436 case PlatformAgnosticAvailabilityKind::Deprecated:
395437 case PlatformAgnosticAvailabilityKind::Unavailable:
396438 case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
439+ case PlatformAgnosticAvailabilityKind::NoAsync:
397440 return false ;
398441 case PlatformAgnosticAvailabilityKind::None:
399442 case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
@@ -771,6 +814,8 @@ static void printAvailableAttr(const AvailableAttr *Attr, ASTPrinter &Printer,
771814 Printer << " , unavailable" ;
772815 else if (Attr->isUnconditionallyDeprecated ())
773816 Printer << " , deprecated" ;
817+ else if (Attr->isNoAsync ())
818+ Printer << " , noasync" ;
774819
775820 if (Attr->Introduced )
776821 Printer << " , introduced: " << Attr->Introduced .getValue ().getAsString ();
@@ -974,6 +1019,8 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
9741019
9751020 case DAK_Available: {
9761021 auto Attr = cast<AvailableAttr>(this );
1022+ if (Options.SuppressNoAsyncAvailabilityAttr && Attr->isNoAsync ())
1023+ return false ;
9771024 if (!Options.PrintSPIs && Attr->IsSPI ) {
9781025 assert (Attr->hasPlatform ());
9791026 assert (Attr->Introduced .hasValue ());
@@ -1705,6 +1752,7 @@ bool AvailableAttr::isUnconditionallyUnavailable() const {
17051752 case PlatformAgnosticAvailabilityKind::Deprecated:
17061753 case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
17071754 case PlatformAgnosticAvailabilityKind::PackageDescriptionVersionSpecific:
1755+ case PlatformAgnosticAvailabilityKind::NoAsync:
17081756 return false ;
17091757
17101758 case PlatformAgnosticAvailabilityKind::Unavailable:
@@ -1722,6 +1770,7 @@ bool AvailableAttr::isUnconditionallyDeprecated() const {
17221770 case PlatformAgnosticAvailabilityKind::UnavailableInSwift:
17231771 case PlatformAgnosticAvailabilityKind::SwiftVersionSpecific:
17241772 case PlatformAgnosticAvailabilityKind::PackageDescriptionVersionSpecific:
1773+ case PlatformAgnosticAvailabilityKind::NoAsync:
17251774 return false ;
17261775
17271776 case PlatformAgnosticAvailabilityKind::Deprecated:
@@ -1731,6 +1780,10 @@ bool AvailableAttr::isUnconditionallyDeprecated() const {
17311780 llvm_unreachable (" Unhandled PlatformAgnosticAvailabilityKind in switch." );
17321781}
17331782
1783+ bool AvailableAttr::isNoAsync () const {
1784+ return PlatformAgnostic == PlatformAgnosticAvailabilityKind::NoAsync;
1785+ }
1786+
17341787llvm::VersionTuple AvailableAttr::getActiveVersion (const ASTContext &ctx) const {
17351788 if (isLanguageVersionSpecific ()) {
17361789 return ctx.LangOpts .EffectiveLanguageVersion ;
0 commit comments