Commit Graph

231 Commits

Author SHA1 Message Date
Allan Shortlidge
b4e2cff9f9 AST: Introduce SemanticAvailableAttr::isSPI(). 2025-01-08 08:17:26 -08:00
Allan Shortlidge
0421835b12 AST: Adopt SemanticAvailableAttr in availability attribute inference. 2025-01-07 07:31:13 -08:00
Allan Shortlidge
dcfe563294 AST: Remove AvailabilityInference::availableRangeAndAttr() 2025-01-07 07:31:13 -08:00
Allan Shortlidge
efa1afff11 AST: Introduce SemanticAvailableAttr::getIntroducedRange().
It replaces the overload of AvailabilityInference::availableRange() that takes
an AvailableAttr.
2025-01-07 07:31:12 -08:00
Allan Shortlidge
f1d0885458 AST: Adopt SemanticAvailableAttr in AvailabilityConstraint. 2025-01-07 07:31:12 -08:00
Allan Shortlidge
4ed62e3154 AST: Introduce Decl::getAvailableAttrForPlatformIntroduction().
It replaces `AvailabilityInference::attrForAnnotatedAvailableRange()`.
2025-01-07 07:31:12 -08:00
Allan Shortlidge
d0f63a0753 AST: Split Availability.h into multiple headers.
Put AvailabilityRange into its own header with very few dependencies so that it
can be included freely in other headers that need to use it as a complete type.

NFC.
2025-01-03 18:36:04 -08:00
Allan Shortlidge
00aae6ead5 AST: Return SemanticAvailableAttr from Decl::getUnavailableAttr(). 2024-12-19 17:22:51 -08:00
Allan Shortlidge
055a9ecd07 AST: Return a SemanticAvailableAttr from Decl::getDeprecatedAttr(). 2024-12-19 17:22:51 -08:00
Allan Shortlidge
2bc0427279 AST: Update isBetterThan() to take SemanticAvailableAttrs. 2024-12-19 17:22:51 -08:00
Allan Shortlidge
000c9da3ed AST: Return SemanticAvailableAttr from Decl::getActiveAvailableAttrForCurrentPlatform(). 2024-12-19 17:22:51 -08:00
Allan Shortlidge
2ca2237767 AST: Return a SemanticAvailableAttr from Decl::getNoAsyncAttr(). 2024-12-19 17:22:51 -08:00
Allan Shortlidge
0de339db1c AST: Introduce a SemanticAvailableAttr::isNoAsync() convenience. 2024-12-19 17:22:04 -08:00
Allan Shortlidge
111661e1d2 AST: Move several queries to SemanticAvailableAttr. 2024-12-19 08:40:01 -08:00
Allan Shortlidge
17dfbf5053 AST: Adopt SemanticAvailableAttr for SpecializeAttr. 2024-12-19 08:40:00 -08:00
Allan Shortlidge
f42ca1e758 AST: Introduce Decl::getSemanticAvailableAttr().
This convenience returns an optional `SemanticAvailableAttr` (since in the
future, lookup of the `AvailabilityDomain` can fail). It replaces
`Decl::getDomainForAvailableAttr()`, since most callers will need to form a
`SemanticAvailableAttr` with the resulting domain anyways.
2024-12-19 08:40:00 -08:00
Allan Shortlidge
0288eaa3b7 AST: Introduce Decl::getSemanticAvailableAttrs().
This new attribute iterator returned from the query makes it simpler to
implement algorithms that need access to both the `AvailableAttr *` and its
corresponding `AvailabilityDomain`. This is also work towards making it
possible to return an optional `AvailabilityDomain` from
`Decl::getDomainForAvailableAttr()`.
2024-12-19 08:40:00 -08:00
Allan Shortlidge
4da7f83f84 AST: Remove Decl::getSemanticAvailableRangeAttr().
This query's functionality was not useful enough to be exposed on `Decl` and
cached in the request evaluator. Instead, just share a local implementation of
it in `TypeCheckAttr.cpp`.
2024-12-05 15:47:24 -08:00
Allan Shortlidge
64f9d5b945 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
2024-12-02 23:00:43 -08:00
Allan Shortlidge
b2cc10cd94 AST: Introduce Decl::isSemanticallyUnavailable().
Adopt it in a few places as a replacement for `Decl::getSemanticUnavailableAttr()`.
2024-12-02 23:00:43 -08:00
Allan Shortlidge
0ff25ca7b0 AST: Implement Decl::isUnreachableAtRuntime() using a request. 2024-12-02 23:00:43 -08:00
Allan Shortlidge
71afa86b6c AST: Fix Decl::isUnreachableAtRuntime() for obsolete decls in unavailable decls. 2024-12-02 23:00:43 -08:00
Allan Shortlidge
d8c946d186 AST: Introduce Decl::getActiveAvailableAttrForCurrentPlatform(). 2024-12-02 07:35:58 -08:00
Allan Shortlidge
5cdcb5d116 AST: Introduce Decl::getNoAsyncAttr(). 2024-12-02 07:35:58 -08:00
Allan Shortlidge
5143382265 AST: Introduce Decl::isUnavailableInCurrentSwiftVersion(). 2024-12-02 07:35:58 -08:00
Allan Shortlidge
c5398e17d3 AST: Introduce Decl::getDeprecatedAttr().
It replaces `DeclAttr::getDeprecated()` as the designated way to query for the
attribute that makes a decl deprecated.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
3e50a90c45 AST: Introduce Decl::getUnavailableAttr().
It replaces `DeclAttr::getUnavailable()` and `AvailableAttr::isUnavailable()`
as the designated way to query for the attribute that makes a decl unavailable.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
1dc7aa5b7b AST: Introduce Decl::isUnavailable().
Replace calls to `AvailableAttr::isUnavailable()` with `Decl::isUnavailable()`.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
cd13d7d777 AST: Remove AvailableAttr::RenameDecl.
The renamed decl is now stored exclusively in the split request evaluator
storage, which is more efficient since most availability attributes do not
specify a renamed decl.
2024-11-29 10:35:02 -05:00
Allan Shortlidge
b6353b0abd AST: Don't copy cached rename decls when inferring availability. 2024-11-29 10:34:49 -05:00
Allan Shortlidge
e6741d5e9e AST: Adopt ValueDecl::getRenamedDecl().
This unblocks removing `RenameDecl` from `AvailableAttr`.
2024-11-29 10:34:49 -05:00
Allan Shortlidge
36230cd9c6 AST: Use an accessor to get the PlatformKind from an AvailableAttr. 2024-11-21 09:10:36 -08:00
Allan Shortlidge
48f10f7dcf AST: Centralize definition of future availability triple. 2024-11-20 10:08:45 -08:00
Allan Shortlidge
e881a443b7 AST: Upstream missing future availability range for visionOS. 2024-11-20 10:08:45 -08:00
Allan Shortlidge
b3f6421091 AST: Remove DeclAttributes::getPotentiallyUnavailable().
This utility duplicated logic that is now meant to be encapsulated by
`getUnsatisfiedAvailabilityConstraint()`.
2024-11-19 17:19:51 -08:00
Allan Shortlidge
4fa02cd11a AST: Rename UnmetAvailabilityRequirement to AvailabilityConstraint.
Also, pull its definition out into a separate header.
2024-11-04 19:58:28 -08:00
Allan Shortlidge
ca34f42419 AST: Introduce UnmetAvailabilityRequirement::isConditionallySatisfiable(). 2024-11-03 11:37:01 -08:00
Allan Shortlidge
5dc654c73b AST: Move UnmetAvailabilityRequirement to Availability.h.
This type will need to be used outside of Sema.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
0e4c881eb3 AST: Store the IsSPI bit of AvailableAttr inline in DecAttribute.
Reduces the layout requirements for `AvailableAttr` by one byte.
2024-10-30 14:29:45 -07:00
Allan Shortlidge
4c6b8a1d97 AST: Introduce AvailabilityInference::availableRangeAndAttr().
Also, clean up some documentation.
2024-10-24 20:06:35 -07:00
Allan Shortlidge
0730209302 AST: Move AvailabilityContext into its own header and cpp file. 2024-10-21 15:16:08 -07:00
Allan Shortlidge
4cb783fc92 AST: Store unavailability and deprecation status in AvailabilityContext. 2024-10-21 15:16:08 -07:00
Allan Shortlidge
47e41855d0 AST/Sema: Adopt AvailabilityContext in TypeRefinementContext.
Begin using `AvailabilityContext` as the availability representation in
`TypeRefinementContext`, instead of only storing platform introduction
availability ranges.

There should be no functional changes since this just changes the
representation of the existing information stored by `TypeRefinementContext`.
However, in the future `AvailabilityContext` will be expanded to represent
additional availability constraints.
2024-10-17 17:32:05 -07:00
Allan Shortlidge
439c5951ec AST: Introduce AvailabilityContext.
This class is designed to be a compact representation of the active
availability constraints in a specific scope. For now, it only models platform
introduction availability but it will soon be updated to cover additional
availability constraints, like platform unavailability.

In anticipation of needing to reference `AvailabilityContext`s from
`TypeRefinementContext`s and increasing memory requirements for these contexts,
a cache of uniqued instances of `AvailabilityContext` are stored in a
`llvm::FoldingSet` on `ASTContext`.
2024-10-17 11:26:28 -07:00
Allan Shortlidge
7819dd7833 AST/Sema: Remove unnecessary ASTContext parameters from availability APIs.
Many of the methods on `AvailabilityInference` take both a `Decl` and an
`ASTContext`, which is redundant.
2024-10-14 17:46:53 -07:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
Allan Shortlidge
01215b0e3d AST: Remove UnavailabilityReason.
`UnavailabilityReason` does not live up to its name because it only models
potential unavailability due to an unmet OS version requirement. It does not
model unavailability caused by explicit annotation, language mode requirements,
obsoletion, etc. `AvailabilityContext` already models an OS version
requirement, so use it instead.

NFC.
2024-09-02 16:47:14 -07:00
Allan Shortlidge
8052e3f9dc AST: Remove 'OS' from AvailabilityContext member names.
An `AvailabilityContext` represents an abstract version range in which
something is available. In the future, these version ranges may not necessarily
always correspond to operating system version ranges.

NFC.
2024-09-02 16:47:14 -07:00
Allan Shortlidge
018234fabf AST: Remove IsSPI from AvailabilityContext.
It only existed to make `Decl::isAvailableAsSPI()` convenient to implement.

NFC.
2024-09-02 16:47:14 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00