@@ -493,26 +493,23 @@ Decl::getSemanticAvailableAttr(const AvailableAttr *attr) const {
493
493
return SemanticAvailableAttr (attr, domainForAvailableAttr (attr));
494
494
}
495
495
496
- const AvailableAttr *
496
+ std::optional<SemanticAvailableAttr>
497
497
Decl::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;
503
499
504
- if (!attr->hasPlatform ())
500
+ for (auto attr : getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
501
+ if (!attr.isPlatformSpecific ())
505
502
continue ;
506
503
507
504
if (ignoreAppExtensions &&
508
- isApplicationExtensionPlatform (attr-> getPlatform ()))
505
+ isApplicationExtensionPlatform (attr. getPlatform ()))
509
506
continue ;
510
507
511
508
// We have an attribute that is active for the platform, but is it more
512
509
// specific than our current best?
513
510
if (!bestAttr || inheritsAvailabilityFromPlatform (
514
- attr-> getPlatform (), bestAttr->getPlatform ())) {
515
- bestAttr = attr;
511
+ attr. getPlatform (), bestAttr->getPlatform ())) {
512
+ bestAttr. emplace ( attr) ;
516
513
}
517
514
}
518
515
@@ -522,13 +519,13 @@ Decl::getActiveAvailableAttrForCurrentPlatform(bool ignoreAppExtensions) const {
522
519
const AvailableAttr *Decl::getDeprecatedAttr () const {
523
520
auto &ctx = getASTContext ();
524
521
const AvailableAttr *result = nullptr ;
525
- const AvailableAttr * bestActive = getActiveAvailableAttrForCurrentPlatform ();
522
+ auto bestActive = getActiveAvailableAttrForCurrentPlatform ();
526
523
527
524
for (auto semanticAttr :
528
525
getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
529
526
auto attr = semanticAttr.getParsedAttr ();
530
527
531
- if (attr->hasPlatform () && (!bestActive || attr != bestActive))
528
+ if (attr->hasPlatform () && (!bestActive || semanticAttr != bestActive))
532
529
continue ;
533
530
534
531
// Unconditional deprecated.
@@ -560,13 +557,13 @@ const AvailableAttr *Decl::getDeprecatedAttr() const {
560
557
const AvailableAttr *Decl::getSoftDeprecatedAttr () const {
561
558
auto &ctx = getASTContext ();
562
559
const AvailableAttr *result = nullptr ;
563
- const AvailableAttr * bestActive = getActiveAvailableAttrForCurrentPlatform ();
560
+ auto bestActive = getActiveAvailableAttrForCurrentPlatform ();
564
561
565
562
for (auto semanticAttr :
566
563
getSemanticAvailableAttrs (/* includingInactive=*/ false )) {
567
564
auto attr = semanticAttr.getParsedAttr ();
568
565
569
- if (attr->hasPlatform () && (!bestActive || attr != bestActive))
566
+ if (attr->hasPlatform () && (!bestActive || semanticAttr != bestActive))
570
567
continue ;
571
568
572
569
std::optional<llvm::VersionTuple> deprecatedVersion = attr->Deprecated ;
@@ -626,7 +623,7 @@ static const AvailableAttr *
626
623
getDeclUnavailableAttr (const Decl *D, bool ignoreAppExtensions) {
627
624
auto &ctx = D->getASTContext ();
628
625
const AvailableAttr *result = nullptr ;
629
- const AvailableAttr * bestActive =
626
+ auto bestActive =
630
627
D->getActiveAvailableAttrForCurrentPlatform (ignoreAppExtensions);
631
628
632
629
for (auto semanticAttr :
@@ -635,7 +632,7 @@ getDeclUnavailableAttr(const Decl *D, bool ignoreAppExtensions) {
635
632
636
633
// If this is a platform-specific attribute and it isn't the most
637
634
// specific attribute for the current platform, we're done.
638
- if (attr->hasPlatform () && (!bestActive || attr != bestActive))
635
+ if (attr->hasPlatform () && (!bestActive || semanticAttr != bestActive))
639
636
continue ;
640
637
641
638
if (ignoreAppExtensions &&
0 commit comments