@@ -3426,7 +3426,6 @@ class VarDeclUsageChecker : public ASTWalker {
3426
3426
// / from its associated function body.
3427
3427
class OpaqueUnderlyingTypeChecker : public ASTWalker {
3428
3428
using Candidate = std::tuple<Expr *, SubstitutionMap, /* isUnique=*/ bool >;
3429
- using AvailabilityContext = IfStmt *;
3430
3429
3431
3430
ASTContext &Ctx;
3432
3431
AbstractFunctionDecl *Implementation;
@@ -3436,16 +3435,16 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3436
3435
// / A set of all candidates with unique signatures.
3437
3436
SmallPtrSet<const void *, 4 > UniqueSignatures;
3438
3437
3439
- // / Represents a current availability context . `nullptr` means that
3440
- // / there are no restrictions .
3441
- AvailabilityContext CurrentAvailability = nullptr ;
3438
+ // / The active `IfStmt` that restricts availability . `nullptr` means that
3439
+ // / there are is no restriction .
3440
+ IfStmt *CurrentIfStmt = nullptr ;
3442
3441
3443
3442
// / All of the candidates together with their availability.
3444
3443
// /
3445
3444
// / If a candidate is found in non-`if #available` context or
3446
3445
// / `if #available` has other dynamic conditions, it covers 'all'
3447
3446
// / versions and the context is set to `nullptr`.
3448
- SmallVector<std::pair<AvailabilityContext , Candidate>, 4 > Candidates;
3447
+ SmallVector<std::pair<IfStmt * , Candidate>, 4 > Candidates;
3449
3448
3450
3449
bool HasInvalidReturn = false ;
3451
3450
@@ -3534,11 +3533,11 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3534
3533
SmallVector<Candidate, 4 > universallyUniqueCandidates;
3535
3534
3536
3535
for (const auto &entry : Candidates) {
3537
- AvailabilityContext availability = entry.first ;
3536
+ IfStmt *stmt = entry.first ;
3538
3537
const auto &candidate = entry.second ;
3539
3538
3540
3539
// Unique candidate without availability context.
3541
- if (!availability && std::get<2 >(candidate))
3540
+ if (!stmt && std::get<2 >(candidate))
3542
3541
universallyUniqueCandidates.push_back (candidate);
3543
3542
}
3544
3543
@@ -3649,16 +3648,16 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3649
3648
SubstitutionMap universalSubstMap = std::get<1 >(universallyAvailable);
3650
3649
3651
3650
for (const auto &entry : Candidates) {
3652
- auto availabilityContext = entry.first ;
3651
+ auto stmt = entry.first ;
3653
3652
const auto &candidate = entry.second ;
3654
3653
3655
- if (!availabilityContext )
3654
+ if (!stmt )
3656
3655
continue ;
3657
3656
3658
3657
unsigned neverAvailableCount = 0 , alwaysAvailableCount = 0 ;
3659
3658
SmallVector<AvailabilityCondition, 4 > conditions;
3660
3659
3661
- for (const auto &elt : availabilityContext ->getCond ()) {
3660
+ for (const auto &elt : stmt ->getCond ()) {
3662
3661
auto condition = elt.getAvailability ();
3663
3662
3664
3663
auto availabilityRange = condition->getAvailableRange ();
@@ -3697,7 +3696,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3697
3696
// If all the conditions were trivially true, then this candidate is
3698
3697
// effectively a universally available candidate and the rest of the
3699
3698
// candidates should be ignored since they are unreachable.
3700
- if (alwaysAvailableCount == availabilityContext ->getCond ().size ()) {
3699
+ if (alwaysAvailableCount == stmt ->getCond ().size ()) {
3701
3700
universalSubstMap = std::get<1 >(candidate);
3702
3701
break ;
3703
3702
}
@@ -3746,7 +3745,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3746
3745
return Action::Stop ();
3747
3746
}
3748
3747
3749
- Candidates.push_back ({CurrentAvailability , candidate});
3748
+ Candidates.push_back ({CurrentIfStmt , candidate});
3750
3749
return Action::SkipNode (E);
3751
3750
}
3752
3751
@@ -3758,7 +3757,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3758
3757
if (Parent.getAsStmt () != Body) {
3759
3758
// If this is not a top-level `if`, let's drop
3760
3759
// contextual information that has been set previously.
3761
- CurrentAvailability = nullptr ;
3760
+ CurrentIfStmt = nullptr ;
3762
3761
return Action::Continue (S);
3763
3762
}
3764
3763
@@ -3785,8 +3784,8 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
3785
3784
// Note that we are about to walk into a return statement
3786
3785
// that is located in a `if #available` without any other
3787
3786
// conditions.
3788
- llvm::SaveAndRestore<AvailabilityContext > context (
3789
- CurrentAvailability , If);
3787
+ llvm::SaveAndRestore<IfStmt * > context (
3788
+ CurrentIfStmt , If);
3790
3789
3791
3790
Return->getResult ()->walk (*this );
3792
3791
}
0 commit comments