mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user