Sema: Improve diagnostics for decls more available than their containers.

Adopt new request-based utilities for looking up the enclosing declaration's availability when type checking an `@available` attribute. This consolidates implementations of the lookup and improves diagnostics by catching more cases where declarations are more available than their containers.
This commit is contained in:
Allan Shortlidge
2023-01-06 14:11:24 -08:00
parent 6d657c90af
commit abf4d127a4
4 changed files with 50 additions and 44 deletions

View File

@@ -1101,17 +1101,21 @@ public:
/// Retrieve the @available attribute that provides the OS version range that
/// this declaration is available in.
///
/// The attribute may come from another declaration, since availability
/// could be inherited from a parent declaration.
/// This attribute may come from an enclosing decl since availability is
/// inherited. The second member of the returned pair is the decl that owns
/// the attribute.
Optional<std::pair<const AvailableAttr *, const Decl *>>
getSemanticAvailableRangeAttr() const;
/// Retrieve the @available attribute that makes this declaration unavailable,
/// if any.
///
/// The attribute may come from another declaration, since unavailability
/// could be inherited from a parent declaration. This is a broader notion of
/// unavailability than is checked by \c AvailableAttr::isUnavailable.
/// This attribute may come from an enclosing decl since availability is
/// inherited. The second member of the returned pair is the decl that owns
/// the attribute.
///
/// Note that this notion of unavailability is broader than that which is
/// checked by \c AvailableAttr::isUnavailable.
Optional<std::pair<const AvailableAttr *, const Decl *>>
getSemanticUnavailableAttr() const;