Skip to content

Commit fc2b5be

Browse files
committed
AST: Remove Decl::isSemanticallyUnavailable().
It can be replaced by querying the `AvailabilityContext` for a declaration directly.
1 parent ef1a1d1 commit fc2b5be

File tree

6 files changed

+6
-16
lines changed

6 files changed

+6
-16
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,11 +1475,6 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl>, public Swi
14751475
/// extension) that makes it unavailable.
14761476
std::optional<SemanticAvailableAttr> getUnavailableAttr() const;
14771477

1478-
/// Returns true if the decl is effectively always unavailable in the current
1479-
/// compilation context. This query differs from \c isUnavailable() because it
1480-
/// takes the availability of parent declarations into account.
1481-
bool isSemanticallyUnavailable() const;
1482-
14831478
/// Returns true if code associated with this declaration should be considerd
14841479
/// unreachable at runtime because the declaration is unavailable in all
14851480
/// execution contexts in which the code may run. This result takes the

lib/AST/Availability.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,13 +645,6 @@ SemanticDeclAvailabilityRequest::evaluate(Evaluator &evaluator,
645645
return SemanticDeclAvailability::PotentiallyAvailable;
646646
}
647647

648-
bool Decl::isSemanticallyUnavailable() const {
649-
auto availability = evaluateOrDefault(
650-
getASTContext().evaluator, SemanticDeclAvailabilityRequest{this},
651-
SemanticDeclAvailability::PotentiallyAvailable);
652-
return availability != SemanticDeclAvailability::PotentiallyAvailable;
653-
}
654-
655648
bool Decl::isUnreachableAtRuntime() const {
656649
auto availability = evaluateOrDefault(
657650
getASTContext().evaluator, SemanticDeclAvailabilityRequest{this},

lib/SIL/IR/SILProfiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "swift/SIL/SILProfiler.h"
1414
#include "swift/AST/ASTWalker.h"
15+
#include "swift/AST/AvailabilityContext.h"
1516
#include "swift/AST/Decl.h"
1617
#include "swift/AST/Expr.h"
1718
#include "swift/AST/Module.h"
@@ -117,7 +118,7 @@ static bool shouldProfile(SILDeclRef Constant) {
117118

118119
if (auto *D = DC->getInnermostDeclarationDeclContext()) {
119120
// Do not profile AST nodes in unavailable contexts.
120-
if (D->isSemanticallyUnavailable()) {
121+
if (AvailabilityContext::forDeclSignature(D).isUnavailable()) {
121122
LLVM_DEBUG(llvm::dbgs() << "Skipping ASTNode: unavailable context\n");
122123
return false;
123124
}

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5455,7 +5455,7 @@ TypeChecker::diagnosticIfDeclCannotBeUnavailable(const Decl *D,
54555455
auto parentIsUnavailable = [](const Decl *D) -> bool {
54565456
if (auto *parent =
54575457
AvailabilityInference::parentDeclForInferredAvailability(D)) {
5458-
return parent->isSemanticallyUnavailable();
5458+
return AvailabilityContext::forDeclSignature(parent).isUnavailable();
54595459
}
54605460
return false;
54615461
};

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ checkOverrideUnavailability(ValueDecl *override, ValueDecl *base) {
19331933
if (auto *overrideParent = override->getDeclContext()->getAsDecl()) {
19341934
// If the parent of the override is unavailable, then the unavailability of
19351935
// the override decl is irrelevant.
1936-
if (overrideParent->isSemanticallyUnavailable())
1936+
if (AvailabilityContext::forDeclSignature(overrideParent).isUnavailable())
19371937
return {OverrideUnavailabilityStatus::Ignored, std::nullopt};
19381938
}
19391939

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1885,7 +1885,8 @@ RequirementCheck WitnessChecker::checkWitness(ValueDecl *requirement,
18851885
}
18861886

18871887
if (auto adoptingNominal = DC->getSelfNominalTypeDecl()) {
1888-
if (adoptingNominal->isSemanticallyUnavailable())
1888+
if (AvailabilityContext::forDeclSignature(adoptingNominal)
1889+
.isUnavailable())
18891890
return true;
18901891
}
18911892

0 commit comments

Comments
 (0)