@@ -493,26 +493,23 @@ Decl::getSemanticAvailableAttr(const AvailableAttr *attr) const {
493493 return SemanticAvailableAttr (attr, domainForAvailableAttr (attr));
494494}
495495
496- const AvailableAttr *
496+ std::optional<SemanticAvailableAttr>
497497Decl::getActiveAvailableAttrForCurrentPlatform (bool ignoreAppExtensions) const {
498- const AvailableAttr *bestAttr = nullptr ;
499-
500- for (auto semanticAttr :
501- getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
502- auto attr = semanticAttr.getParsedAttr ();
498+ std::optional<SemanticAvailableAttr> bestAttr;
503499
504- if (!attr->hasPlatform ())
500+ for (auto attr : getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
501+ if (!attr.isPlatformSpecific ())
505502 continue ;
506503
507504 if (ignoreAppExtensions &&
508- isApplicationExtensionPlatform (attr-> getPlatform ()))
505+ isApplicationExtensionPlatform (attr. getPlatform ()))
509506 continue ;
510507
511508 // We have an attribute that is active for the platform, but is it more
512509 // specific than our current best?
513510 if (!bestAttr || inheritsAvailabilityFromPlatform (
514- attr-> getPlatform (), bestAttr->getPlatform ())) {
515- bestAttr = attr;
511+ attr. getPlatform (), bestAttr->getPlatform ())) {
512+ bestAttr. emplace ( attr) ;
516513 }
517514 }
518515
@@ -522,13 +519,13 @@ Decl::getActiveAvailableAttrForCurrentPlatform(bool ignoreAppExtensions) const {
522519const AvailableAttr *Decl::getDeprecatedAttr () const {
523520 auto &ctx = getASTContext ();
524521 const AvailableAttr *result = nullptr ;
525- const AvailableAttr * bestActive = getActiveAvailableAttrForCurrentPlatform ();
522+ auto bestActive = getActiveAvailableAttrForCurrentPlatform ();
526523
527524 for (auto semanticAttr :
528525 getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
529526 auto attr = semanticAttr.getParsedAttr ();
530527
531- if (attr->hasPlatform () && (!bestActive || attr != bestActive))
528+ if (attr->hasPlatform () && (!bestActive || semanticAttr != bestActive))
532529 continue ;
533530
534531 // Unconditional deprecated.
@@ -560,13 +557,13 @@ const AvailableAttr *Decl::getDeprecatedAttr() const {
560557const AvailableAttr *Decl::getSoftDeprecatedAttr () const {
561558 auto &ctx = getASTContext ();
562559 const AvailableAttr *result = nullptr ;
563- const AvailableAttr * bestActive = getActiveAvailableAttrForCurrentPlatform ();
560+ auto bestActive = getActiveAvailableAttrForCurrentPlatform ();
564561
565562 for (auto semanticAttr :
566563 getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
567564 auto attr = semanticAttr.getParsedAttr ();
568565
569- if (attr->hasPlatform () && (!bestActive || attr != bestActive))
566+ if (attr->hasPlatform () && (!bestActive || semanticAttr != bestActive))
570567 continue ;
571568
572569 std::optional<llvm::VersionTuple> deprecatedVersion = attr->Deprecated ;
@@ -626,7 +623,7 @@ static const AvailableAttr *
626623getDeclUnavailableAttr (const Decl *D, bool ignoreAppExtensions) {
627624 auto &ctx = D->getASTContext ();
628625 const AvailableAttr *result = nullptr ;
629- const AvailableAttr * bestActive =
626+ auto bestActive =
630627 D->getActiveAvailableAttrForCurrentPlatform (ignoreAppExtensions);
631628
632629 for (auto semanticAttr :
@@ -635,7 +632,7 @@ getDeclUnavailableAttr(const Decl *D, bool ignoreAppExtensions) {
635632
636633 // If this is a platform-specific attribute and it isn't the most
637634 // specific attribute for the current platform, we're done.
638- if (attr->hasPlatform () && (!bestActive || attr != bestActive))
635+ if (attr->hasPlatform () && (!bestActive || semanticAttr != bestActive))
639636 continue ;
640637
641638 if (ignoreAppExtensions &&
0 commit comments