Commit Graph

721 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
57b6d1e90b [ASTGen] Generate "minus" number literal expression 2025-02-17 21:34:11 -08:00
Rintaro Ishizaki
c7e8f58174 Merge pull request #79438 from rintaro/astgen-static-var
[ASTGen] Correctly store static spelling and location to PBD
2025-02-17 15:59:43 -08:00
Rintaro Ishizaki
b7b28b6d8e [ASTGen] Correctly store static spelling and location to PBD 2025-02-17 11:16:53 -08:00
Rintaro Ishizaki
94402b6c9d [ASTGen] Generate LifetimeAttr 2025-02-17 08:56:29 -08:00
Rintaro Ishizaki
6d85bb58c5 Merge pull request #79412 from rintaro/astgen-typeattrs
[ASTGen] Generate OpaqueReturnTypeOfTypeAttr
2025-02-16 13:55:39 -08:00
Rintaro Ishizaki
84875d147e [ASTGen] Bridge ASTContext.Id_x 2025-02-16 05:22:46 -08:00
Rintaro Ishizaki
0ced6e06b4 [ASTGen] Generate CaptureListExpr
Move the capture list entry construction logic to
CaptureListEntry::createParsed() so that ASTGen can use it.
2025-02-16 05:22:46 -08:00
Rintaro Ishizaki
214315b1cc [ASTGen] Generate several type attributes
Also rework existing type attribute generate functino to use standard
attribute generation facilities.
2025-02-14 18:18:24 -08:00
Rintaro Ishizaki
137e279d62 Merge pull request #79368 from rintaro/astgen-astnode
[ASTGen] Eliminate ASTGen.ASTNode
2025-02-14 11:53:17 -08:00
Rintaro Ishizaki
10aac858fb Merge pull request #79379 from rintaro/astgen-conventiontypeattr
[ASTGen] Generate ConventionTypeAttr
2025-02-14 07:10:27 -08:00
Rintaro Ishizaki
9229b0746d Merge pull request #79374 from rintaro/astgen-objectliteralexpr
[ASTGen] Generate ObjectLiteralExpr
2025-02-14 07:10:10 -08:00
Rintaro Ishizaki
f2db96cc60 [ASTGen] Eliminate ASTGen.ASTNode
We can simply use `BridgedASTNode`, no need to have its own ASTNode
2025-02-14 07:05:10 -08:00
Allan Shortlidge
06030d66aa AST: Introduce AvailabilityDomainOrIdentifier.
It provides a common way to represent either a parsed domain identifier or the
resolved domain.

NFC.
2025-02-13 21:18:05 -08:00
Rintaro Ishizaki
f08bf56722 [ASTGen] Generate ConventionTypeAttr
E.g. `@convention(c)`
2025-02-13 16:19:20 -08:00
Rintaro Ishizaki
e1dfed3f13 [ASTGen] Bridge TypeAttribute subclasses 2025-02-13 16:19:20 -08:00
Rintaro Ishizaki
13380da3b4 [ASTGen] Generate ObjectLiteralExpr
e.g. '#imageLiteral(..)'
2025-02-13 16:17:47 -08:00
Rintaro Ishizaki
e066bb266b Merge pull request #79355 from rintaro/astgen-toplevelvardecl
[ASTGen] Generate PatternBindingDecl at top level
2025-02-13 09:43:10 -08:00
Rintaro Ishizaki
73164a0ffd Merge pull request #79353 from rintaro/astgen-magic-ident-literal
[ASTGen] Generate MagicIdentifierLiteralExpr
2025-02-13 06:25:09 -08:00
Rintaro Ishizaki
6ea6a31ec7 [ASTGen] Generate TopLevelCodeDecl for PatternBindingDecl
* Instead of hoisting VarDecl in the bridging functions, do it in
  ASTGen.
* Introduce `Decl::forEachDeclToHoist` to handle VarDecls in
  PatternBindingDecl, and EnumElementDecl in EnumCaseDecl.
* Intorduce `withBridgedSwiftClosure(closure:call:)` as a callback
  mechanism between Swift and C++
* In `generate(sourceFile:)`, instead of using `generate(codeBlockItem:)`
  handle `CodeBlockItemSyntax.Item` manually to handle `TLCD` wrapping
  and `VarDecl` hoisting.
* Make `generate(variableDecl:)` handle TLCD correctly.
2025-02-13 00:09:22 -08:00
Allan Shortlidge
670084a9ac AST: Retire PlatformVersionConstraintAvailabilitySpec. 2025-02-12 22:46:58 -08:00
Rintaro Ishizaki
f25104ff24 [ASTGen] Generate MagicIdentifierLiteralExpr 2025-02-12 20:47:52 -08:00
Allan Shortlidge
0722efe97e AST: Retire PlatformAgnosticVersionConstraintAvailabilitySpec. 2025-02-12 20:41:00 -08:00
Allan Shortlidge
6844cfe714 AST: Retire OtherPlatformAvailabilitySpec. 2025-02-12 19:39:30 -08:00
Allan Shortlidge
3142803d2f AST: Remove runtime version from AvailabilitySpec.
Instead of canonicalizing platform versions during parsing and storing two
versions, just canonicalize the parsed version on-demand when its requested.
2025-02-11 20:10:07 -08:00