Skip to content

Commit b493b56

Browse files
committed
Sema: Remove OpaqueUnderlyingTypeChecker::AvailabilityContext.
`AvailabilityContext` is now a fundamental type used throughout the compiler, so it's confusing for `OpaqueUnderlyingTypeChecker` to repurpose this name to represent an `IfStmt`. NFC.
1 parent 7e7b456 commit b493b56

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3426,7 +3426,6 @@ class VarDeclUsageChecker : public ASTWalker {
34263426
/// from its associated function body.
34273427
class OpaqueUnderlyingTypeChecker : public ASTWalker {
34283428
using Candidate = std::tuple<Expr *, SubstitutionMap, /*isUnique=*/bool>;
3429-
using AvailabilityContext = IfStmt *;
34303429

34313430
ASTContext &Ctx;
34323431
AbstractFunctionDecl *Implementation;
@@ -3436,16 +3435,16 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
34363435
/// A set of all candidates with unique signatures.
34373436
SmallPtrSet<const void *, 4> UniqueSignatures;
34383437

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;
34423441

34433442
/// All of the candidates together with their availability.
34443443
///
34453444
/// If a candidate is found in non-`if #available` context or
34463445
/// `if #available` has other dynamic conditions, it covers 'all'
34473446
/// versions and the context is set to `nullptr`.
3448-
SmallVector<std::pair<AvailabilityContext, Candidate>, 4> Candidates;
3447+
SmallVector<std::pair<IfStmt *, Candidate>, 4> Candidates;
34493448

34503449
bool HasInvalidReturn = false;
34513450

@@ -3534,11 +3533,11 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
35343533
SmallVector<Candidate, 4> universallyUniqueCandidates;
35353534

35363535
for (const auto &entry : Candidates) {
3537-
AvailabilityContext availability = entry.first;
3536+
IfStmt *stmt = entry.first;
35383537
const auto &candidate = entry.second;
35393538

35403539
// Unique candidate without availability context.
3541-
if (!availability && std::get<2>(candidate))
3540+
if (!stmt && std::get<2>(candidate))
35423541
universallyUniqueCandidates.push_back(candidate);
35433542
}
35443543

@@ -3649,16 +3648,16 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
36493648
SubstitutionMap universalSubstMap = std::get<1>(universallyAvailable);
36503649

36513650
for (const auto &entry : Candidates) {
3652-
auto availabilityContext = entry.first;
3651+
auto stmt = entry.first;
36533652
const auto &candidate = entry.second;
36543653

3655-
if (!availabilityContext)
3654+
if (!stmt)
36563655
continue;
36573656

36583657
unsigned neverAvailableCount = 0, alwaysAvailableCount = 0;
36593658
SmallVector<AvailabilityCondition, 4> conditions;
36603659

3661-
for (const auto &elt : availabilityContext->getCond()) {
3660+
for (const auto &elt : stmt->getCond()) {
36623661
auto condition = elt.getAvailability();
36633662

36643663
auto availabilityRange = condition->getAvailableRange();
@@ -3697,7 +3696,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
36973696
// If all the conditions were trivially true, then this candidate is
36983697
// effectively a universally available candidate and the rest of the
36993698
// candidates should be ignored since they are unreachable.
3700-
if (alwaysAvailableCount == availabilityContext->getCond().size()) {
3699+
if (alwaysAvailableCount == stmt->getCond().size()) {
37013700
universalSubstMap = std::get<1>(candidate);
37023701
break;
37033702
}
@@ -3746,7 +3745,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
37463745
return Action::Stop();
37473746
}
37483747

3749-
Candidates.push_back({CurrentAvailability, candidate});
3748+
Candidates.push_back({CurrentIfStmt, candidate});
37503749
return Action::SkipNode(E);
37513750
}
37523751

@@ -3758,7 +3757,7 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
37583757
if (Parent.getAsStmt() != Body) {
37593758
// If this is not a top-level `if`, let's drop
37603759
// contextual information that has been set previously.
3761-
CurrentAvailability = nullptr;
3760+
CurrentIfStmt = nullptr;
37623761
return Action::Continue(S);
37633762
}
37643763

@@ -3785,8 +3784,8 @@ class OpaqueUnderlyingTypeChecker : public ASTWalker {
37853784
// Note that we are about to walk into a return statement
37863785
// that is located in a `if #available` without any other
37873786
// conditions.
3788-
llvm::SaveAndRestore<AvailabilityContext> context(
3789-
CurrentAvailability, If);
3787+
llvm::SaveAndRestore<IfStmt *> context(
3788+
CurrentIfStmt, If);
37903789

37913790
Return->getResult()->walk(*this);
37923791
}

0 commit comments

Comments
 (0)