AST: Remove Decl::getSemanticUnavailableAttr().

Also remove the underlying `SemanticUnavailableAttrRequest`, which used memory
very inefficiently in order to cache a detailed answer to what was usually a
much simpler question.

The only remaining use of `Decl::getSemanticUnavailableAttr()` that actually
needed to locate the semantic attribute making a declaration unavailable was in
`TypeCheckAttr.cpp`. The implementation of the request could just be used
directly in that one location. The other remaining callers only needed to know
if the decl was unavailable or not, which there are simpler queries for.

 # Please enter the commit message for your changes. Lines starting
This commit is contained in:
Allan Shortlidge
2024-12-02 13:43:01 -08:00
parent b2cc10cd94
commit 64f9d5b945
7 changed files with 32 additions and 70 deletions

View File

@@ -689,28 +689,6 @@ const AvailableAttr *Decl::getUnavailableAttr(bool ignoreAppExtensions) const {
return nullptr;
}
std::optional<AvailableAttrDeclPair>
SemanticUnavailableAttrRequest::evaluate(Evaluator &evaluator, const Decl *decl,
bool ignoreAppExtensions) const {
// Directly marked unavailable.
if (auto attr = decl->getUnavailableAttr(ignoreAppExtensions))
return std::make_pair(attr, decl);
if (auto *parent =
AvailabilityInference::parentDeclForInferredAvailability(decl))
return parent->getSemanticUnavailableAttr(ignoreAppExtensions);
return std::nullopt;
}
std::optional<AvailableAttrDeclPair>
Decl::getSemanticUnavailableAttr(bool ignoreAppExtensions) const {
auto &eval = getASTContext().evaluator;
return evaluateOrDefault(
eval, SemanticUnavailableAttrRequest{this, ignoreAppExtensions},
std::nullopt);
}
static bool isDeclCompletelyUnavailable(const Decl *decl) {
// Don't trust unavailability on declarations from clang modules.
if (isa<ClangModuleUnit>(decl->getDeclContext()->getModuleScopeContext()))