Commit Graph

803 Commits

Author SHA1 Message Date
Rintaro Ishizaki
664ee9ab21 [ASTGen] Fix 'movesAsLike' in @_rawLayout attribute.
Typo: 'moveAsLike' -> 'movesAsLike'
2025-03-07 10:28:47 -08:00
Rintaro Ishizaki
c669004e4c [ASTGen] Clone expanded AvailabilitySpec to set macro location 2025-03-07 07:18:39 -08:00
Rintaro Ishizaki
ff6cb11bb0 [ASTGen] Introduce 'AvailableAttr::createUnavailableInEmbedded()' 2025-03-07 04:14:50 -08:00
Rintaro Ishizaki
d60f1986a8 [ASTGen] Adopt AvailabilityDomainOrIdentifier scheme
Aligning with libParse
2025-03-07 04:14:50 -08:00
Pavel Yaskevich
a7a9a4d11a [DiagnosticsBridge] Treat empty category name as nil
Default value for `Category` for serialization purposes is
an empty string but it should be handled as `nil` while
bridging because category name cannot be empty when present.
2025-03-06 18:35:02 -08:00
Rintaro Ishizaki
017c0d98ec [ASTGen] Generate AutoDiff attributes
`@differentiable`, `@derivative` and `@transpose`
2025-03-06 10:36:13 -08:00
Doug Gregor
0997a7e016 Merge pull request #79688 from DougGregor/diagnostic-ref-footnotes
[Diagnostics] Reference markdown files for educational notes and diagnostic group documentation
2025-03-05 12:41:16 -08:00
Doug Gregor
398e1ad580 [Diagnostics] Always provide a URL for the category documentation 2025-03-04 09:44:37 -08:00
Artem Chikin
13a8d4b88e [Compile Time Values] Add a new experimental feature and the parsing of the '@const' attribute 2025-03-04 07:30:57 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Doug Gregor
6f6b8dd071 [Diagnostics] Provide category name + documentation path
Bridge the category name and educational note computed for the Swift
compiler's diagnostics to the newly-introduced category field for
the swift-syntax diagnostics. This lets the swift-syntax renderer
introduce the category name and (optionally) link to the
documentation.
2025-03-03 22:49:33 -08:00
Allan Shortlidge
aaa0e0a7b3 AST/Parse: Parse custom availability domain specs in if #available(...).
Delay resolution of availability domain identifiers parsed in availability
specifications until type-checking. This allows custom domain specifications to
be written in `if #available` queries.
2025-02-27 23:07:55 -08:00
Doug Gregor
ae6ae33201 [SE-0458] Drop "unsafe" effect for for..in loop in inlined code in interfaces
Only compilers can't handle it, so drop it for now.
2025-02-26 22:06:48 -08:00
Doug Gregor
db0d658351 Merge pull request #79645 from DougGregor/enable-se-0458-by-default
[SE-0458] Enable unsafe expressions / attributes / for..in effects by default
2025-02-26 18:51:58 -08:00
Rintaro Ishizaki
bdc953f418 Merge pull request #79629 from rintaro/astgen-rawlayout
[ASTGen] Generate '@_rawLayout' attribute
2025-02-26 15:13:25 -08:00
Doug Gregor
b7b5a2a19d [SE-0458] Enable unsafe expressions / attributes / for..in effects by default
With the acceptance of SE-0458, allow the use of unsafe expressions, the
@safe and @unsafe attributes, and the `unsafe` effect on the for..in loop
in all Swift code.

Introduce the `-strict-memory-safety` flag detailed in the proposal to
enable strict memory safety checking. This enables a new class of
feature, an optional feature (that is *not* upcoming or experimental),
and which can be detected via `hasFeature(StrictMemorySafety)`.
2025-02-26 12:30:07 -08:00
Rintaro Ishizaki
924e1e8bf1 [ASTGen] Generate '@_rawLayout' attribute
Introduce 'generateTypeRepr(expr:)'.
2025-02-26 10:20:51 -08:00
Rintaro Ishizaki
0c2309898f [ASTGen] Rework type specifiers
Handle multiple specifiers. Hanle previously missing 'sending'
specifiers.
2025-02-26 04:39:38 -08:00
Allan Shortlidge
d07e852db1 Merge pull request #79602 from tshortli/availability-spec-storage
AST: Use `AvailabilityDomainOrIdentifier` to store domains in `AvailabilitySpec`
2025-02-25 14:21:23 -08:00
Allan Shortlidge
c54825b4c3 AST: Use AvailabilityDomainOrIdentifier to store domains in AvailabilitySpec. 2025-02-25 09:02:47 -08:00
Doug Gregor
d9ef00ce16 Look for keywords in inactive #if regions when checking for variable uses
Fixes issue #79555
2025-02-24 18:04:31 -08:00
Rintaro Ishizaki
38bafb3872 Merge pull request #79513 from rintaro/astgen-macro-expanded-syntax 2025-02-24 15:06:24 -08:00
Doug Gregor
115abcb637 Merge pull request #79573 from DougGregor/unsafe-for-in-loop
[SE-0458] Implement "unsafe" effect for the for-in loop
2025-02-24 14:49:45 -08:00
Rintaro Ishizaki
20f589c991 Merge pull request #79547 from rintaro/astgen-small-fixes2 2025-02-24 07:25:53 -08:00
Rintaro Ishizaki
af489ea32b Merge pull request #79544 from rintaro/astgen-small-fixes 2025-02-24 07:25:42 -08:00
Doug Gregor
50801f9c05 [SE-0458] Implement "unsafe" effect for the for-in loop
Memory unsafety in the iteration part of the for-in loop (i.e., the part
that works on the iterator) can be covered by the "unsafe" effect on
the for..in loop, before the pattern.
2025-02-23 22:50:39 -08:00
Allan Shortlidge
ae93451395 ASTGen: Fix a deprecation warning. 2025-02-23 10:53:06 -08:00
Allan Shortlidge
eb6506a1ad AST: Introduce SemanticAvailabilitySpec.
It wraps an type-checked `AvailabilitySpec`, which guarantees that the spec has
a valid `AvailabilityDomain` associated with it. This will unblock moving
AvailabilitySpec domain resolution from parsing to sema.
2025-02-23 10:53:06 -08:00
Rintaro Ishizaki
2bf69742d1 [ASTGen] Fix ReferenceOwnershipAttr modifier
Similar to 7dd8944. Modifier argument is not parsed as a keyword.
2025-02-21 18:38:24 -08:00
Rintaro Ishizaki
4160f101ad [ASTGen] Generate @_unavailableInEmbedded attribute
Which is a sugar of '@available(*, unavailable)' when Embedded feature
is enabled.
2025-02-21 16:54:09 -08:00
Rintaro Ishizaki
efea164d04 [ASTGen] Generate from 'MissingTypeSyntax'
Just emit ErrorTypeRepr
2025-02-21 11:36:29 -08:00
Rintaro Ishizaki
f48282c92b [ASTGen] Generate trailing where clause for SubscriptDecl
It was just missing.
2025-02-21 11:36:29 -08:00
Rintaro Ishizaki
c460947a73 [ASTGen] Wrap optional binding pattern with type annotation 2025-02-21 11:36:29 -08:00
Rintaro Ishizaki
aae50a88c5 [ASTGen] Fix expanded macro buffer parsing and AST generation
Parse expanded buffer into dedicated syntax.

Also rename `BridgedGeneratedSourceFileKindAttribute` to
`BridgedGeneratedSourceFileKindAttributeFromClang` because C++ decl
(i.e. `GeneratedSourceInfo::Kind::AttributeFromClang`) was renamed a
while ago.
2025-02-21 09:56:36 -08:00
Rintaro Ishizaki
8833ff58a2 [AST] Sink the flag collection logic from Parse to AST
* Collect flag in `ParamDecl::setTypeRepr()`.

* [ASTGen] Separate `BridgedParamDecl.setTypeRepr(_:)` from
`BridgedParamDecl.createParsed(_:)` aligning with C++ API. The majority
of the creations don't set the typerepr.

* Update `ParamSpecifierRequest::evaluate` to handle non-implicit
`ParamDecl` without `TypeRepr` (i.e. untyped closure parameter), instead
of `setSpecifier(::Default)` manually in Parse.
2025-02-20 10:04:49 -08:00
Doug Gregor
052958eea9 Merge pull request #79462 from DougGregor/remove-unsafe-from-inline
Remove "unsafe" keyword from expressions when printing inlinable code
2025-02-20 00:41:06 -10:00
Rintaro Ishizaki
2b14a233b7 [ASTGen] Generate generic layout constraint 2025-02-19 16:38:00 -08:00
Rintaro Ishizaki
2ceb8f1e57 Merge pull request #79492 from rintaro/astgen-attr-as-modifier
[ASTGen] Add an assertion for attribute as an modifier
2025-02-19 15:56:55 -08:00
Rintaro Ishizaki
1a5228b31e Merge pull request #79468 from rintaro/astgen-nonisolated
[ASTGen] Generate "nonisolated" decl modifier
2025-02-19 15:46:32 -08:00
Rintaro Ishizaki
6aea6ce2f5 Merge pull request #79469 from rintaro/astgen-custom-type-attr
[ASTGen] Generate CustomAttr on types
2025-02-19 14:06:25 -08:00
Rintaro Ishizaki
81475be976 [ASTGen] Add an assertion for attribute as an modifier 2025-02-19 11:09:53 -08:00
Rintaro Ishizaki
d109a86bb7 [ASTGen] Generate CustomAttr on types
Rework TypeAttribute bridging facilities.
Eliminate the _fake_ `swift::TypeAttributes`, but just use the normal
`BridgedArrayRef` for briding the attribute list. Introduce
`BridgedTypeOrCustomAttr` tagged pointer which resembles
`swift::TypeOrCustomAttr`.
2025-02-18 13:08:50 -08:00
Rintaro Ishizaki
2d9da4dc7a [ASTGen] Generate "nonisolated" decl modifier 2025-02-18 12:35:20 -08:00
Rintaro Ishizaki
43eeb14ba0 [ASTGen] Generate attributes on ParamDecls 2025-02-18 11:14:13 -08:00
Rintaro Ishizaki
6980509f8c [ASTGen] Generate DefaultArgumentInitializer
Rework ParamDecl contextualization.
2025-02-18 11:13:39 -08:00
Doug Gregor
13c82c6f78 Remove "unsafe" keyword from expressions when printing inlinable code
To help older compilers that don't yet support the unsafe expression
deal with the Swift interface files we produce, remove the "unsafe" from
expressions in inlinable code.
2025-02-18 07:14:18 -10:00
Rintaro Ishizaki
31efebe896 Merge pull request #79454 from rintaro/astgen-setteraccess
[ASTGen] Fix SetterAccessAttr e.g. private(set)
2025-02-18 07:09:57 -08:00
Rintaro Ishizaki
015dc8a7ae Merge pull request #79453 from rintaro/astgen-minus-number
[ASTGen] Generate "minus" number literal expression
2025-02-18 07:09:45 -08:00
Rintaro Ishizaki
7dd8944512 [ASTGen] Fix SetterAccessAttr e.g. private(set)
'set' part was not parsed as a keyword. Let's just compare the text.
2025-02-17 22:15:17 -08:00
Rintaro Ishizaki
f172725c36 [ASTGen] Handle reasync and rethrows
Introduce generate(functionSignature:for:)
2025-02-17 22:06:29 -08:00