Commit Graph

244 Commits

Author SHA1 Message Date
John McCall
5a72b785f2 NFC: use visionOS instead of xrOS in the Swift codebase. We can't do
much about the LLVM triple, but we can do our best on the Swift side.
2025-01-22 21:41:14 -05:00
Allan Shortlidge
dfc741e30a AST: Optimize storage of VersionTuples in AvailableAttr.
Representing introduced, deprecated, and obsoleted versions at rest as optional
version tuples is redundant, since the empty version tuple already represents
"version not present".

NFC.
2025-01-22 16:01:19 -08:00
Allan Shortlidge
2908520841 AST: Introduce SemanticAvailableAttrRequest.
This request will finish type checking an AvailableAttr by resolving its domain
and then enforcing any restrictions that the domain has on the attribute, like
disallowing version specifications.

This change just introduces the request and plumbs it through. NFC.
2025-01-22 16:01:19 -08:00
Allan Shortlidge
ba822d1e23 AST: Eliminate remaining direct access to AvailableAttr's fields.
Most of the compiler should use SemanticAvailableAttr instead. In contexts like
ASTDumper where a semantic attribute is unavailable use accessors on
AvailableAttr.

NFC.
2025-01-21 22:56:07 -08:00
Allan Shortlidge
6e1f0ae1c8 AST: Use PointerIntPair in AvailabilityConstraint.
Now that SemanticAvailableAttr is pointer-like, AvailabilityConstraint can be
pointer sized too.

NFC.
2025-01-20 18:24:04 -08:00
Allan Shortlidge
afc5dc98dd AST: Remove inline AvailabilityDomain from SemanticAvailableAttr.
Now that AvailableAttr has storage for its cached AvailabilityDomain, it's no
longer necessary to store an AvailabilityDomain inline in
SemanticAvailableAttr.

NFC.
2025-01-14 11:18:39 -08:00
Allan Shortlidge
51aaacceb7 AST: Remove AvailableAttr::getPlatformAgnosticAvailability(). 2025-01-10 19:18:42 -08:00
Allan Shortlidge
11abffb2f4 AST: Adopt new AvailableAttr constructor in attribute inference.
It was difficult to preserve the existing, buggy behavior of availability
attribute inference with respect to attributes specifying availability for
non-platform-specific domains. Instead, this change improves attribute merging
by tracking every domain independently, and only merging attributes from the
same domain.
2025-01-10 18:43:12 -08:00
Allan Shortlidge
9edd9eed9e AST: Finish adopting SemanticAvailableAttr in AvailabilityInference utilities. 2025-01-08 08:17:27 -08:00
Allan Shortlidge
a882ac6e65 AST: Make some ASTContext parameters const-correct. 2025-01-08 08:17:27 -08:00
Allan Shortlidge
05d342eb98 AST: Remove AvailableAttr::hasPlatform().
Use SemanticAvailableAttr::isPlatformSpecific() instead.
2025-01-08 08:17:27 -08:00
Allan Shortlidge
5058534805 AST: Remove AvailableAttr::prettyPlatformString(). 2025-01-08 08:17:27 -08:00
Allan Shortlidge
c2e8e3060e AST: Remove AvailableAttr::isActivePlatform(). 2025-01-08 08:17:26 -08:00
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