Commit Graph

1278 Commits

Author SHA1 Message Date
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
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
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
Allan Shortlidge
1d509c7120 Merge pull request #79354 from tshortli/retire-availability-spec-subclasses
AST: Retire subclasses of `AvailabilitySpec`
2025-02-13 03:59:44 -08:00
Rintaro Ishizaki
153421f816 Merge pull request #79311 from rintaro/dump-declcontext
[ASTDumper] Dump DeclContext
2025-02-13 03:30:49 -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
Rintaro Ishizaki
563ddc47e2 [AST] Eliminate 'SYNTAX_KIND' from MagicIdentifierKinds.def
Nothing is using it.
2025-02-12 23:19:34 -08:00
Allan Shortlidge
670084a9ac AST: Retire PlatformVersionConstraintAvailabilitySpec. 2025-02-12 22:46:58 -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
Rintaro Ishizaki
71b24665fa [ASTDumper] Dump DeclContext
* Include `DeclContext` of the node where possible
* Add 'default-with-decl-contexts' dump style that dumps the dect context
  hierarchy in addition to the AST
* Support `-dump-parse` with `-dump-ast-format json`
2025-02-12 10:53:33 -08:00
Allan Shortlidge
09f8622b1b AST: Simplify AvailabilitySpec subclasses further.
Remove methods that are specific to AvailabilitySpec subclasses and replace
them with methods on the superclass if necessary.

NFC.
2025-02-11 22:45:43 -08:00
Allan Shortlidge
6daea78ccf AST: Remove AvailabilitySpec.h include from Stmt.h.
Include it where it's actually used instead to improve compile times.
2025-02-11 20:03:01 -08:00
Tony Allevato
4e3e91e3b2 Merge pull request #79218 from allevato/json-ast-inherited
[ASTDumper] Write inherited types correctly.
2025-02-09 20:18:24 -08:00
Tony Allevato
5ff6286dd3 [ASTDumper] Write inherited types correctly.
ASTDumper was never updated to print extra conformance information,
like suppression, preconcurrency, etc. In default mode, we print it
as a comma-delimited list of source-like strings. In JSON mode, we
print objects containing flags.
2025-02-07 10:05:40 -08:00
Michael Gottesman
7e350bb4ce Revert "[concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated."
This reverts commit 0cb64638d0.
2025-02-06 14:05:06 -08:00
Michael Gottesman
f05f08c2c0 Revert "[concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting."
This reverts commit 543b1e6ca3.
2025-02-06 14:04:30 -08:00
Anton Korobeynikov
1e7a1d91fc Emit reabstraction thunks for implicit conversions between T.TangentType and Optional<T>.TangentType (#78076) 2025-02-05 20:57:52 -08:00
Rintaro Ishizaki
df2ada37df [ASTGen] Generate AvailableAttr
* Move `AvailabilitySpec` handling logic to AST, so they can be shared
  between libParse and ASTGen
* Requestify '-define-availability' arguments parsing and parse them
  with 'SwiftParser' according to the 'ParserASTGen' feature flag
* Implement 'AvailableAttr' generation in ASTGen
2025-02-04 23:40:01 -08:00
Tony Allevato
c5f0200680 Merge pull request #79059 from allevato/json-ast-followups
[ASTDumper] Some followups from the initial JSON PR and macro dumping improvements.
2025-02-04 01:13:46 -05:00
Michael Gottesman
543b1e6ca3 [concurrency] Make ActorIsolation::Nonisolated -> CallerIsolationInheriting and delete CallerIsolationInheriting. 2025-02-03 10:56:08 -08:00
Michael Gottesman
0cb64638d0 [concurrency] Add Concurrent/ConcurrentUnsafe and use it instead of ActorIsolation::Nonisolated.
This is just the first part of a larger transition.
2025-02-03 10:56:06 -08:00
Tony Allevato
0d9467e688 Hoist ASTDumpMemberLoading choice up to the frontend call sites. 2025-02-03 11:37:47 -05:00
Tony Allevato
237e79a467 Print the macro's concrete decl ref for any macro expansions.
This gives us the macro's USR, letting us match it up to its
declaration elsewhere.
2025-01-31 11:15:02 -05:00
Anthony Latsis
a84dfc8387 [Gardening] Fix some set but not used variables 2025-01-30 21:34:38 +00:00
Tony Allevato
9d3bcca73f Ensure that top-level macro expansions are in the JSON AST dump. 2025-01-30 12:18:21 -05:00
Tony Allevato
3804110db8 Change parseIfNeeded to an enum to control member loading behavior. 2025-01-30 09:10:15 -05:00
Tony Allevato
5fe10ce86a ASTDumper: Label "interface type" -> "interface_type". 2025-01-29 13:55:00 -05:00
Doug Gregor
9af4d6eb65 Merge pull request #78730 from DougGregor/safe-attr
Introduce the @safe attribute as described in the opt-in safety checking proposal
2025-01-24 19:42:52 -08:00
Tony Allevato
d2fd3479da Additional post-review fixes. 2025-01-24 14:11:20 -05:00
Doug Gregor
4395537fa0 Introduce the @safe attribute as described in the opt-in safety checking proposal 2025-01-23 07:47:17 -08:00
Tony Allevato
f249db3f85 Use cached evaluator results when looking up function types.
Also improve the output for thrown error destinations in
parsable modes.
2025-01-22 14:26:14 -05:00
Tony Allevato
8df48e52ff Address more reviewer feedback. 2025-01-22 14:26:14 -05:00
Tony Allevato
87cabb0f04 Print the buffer ID for non-main buffers and test via macro expansions. 2025-01-22 14:26:13 -05:00
Tony Allevato
a4c64b081d Address most of the simple review feedback. 2025-01-22 14:26:13 -05:00
Tony Allevato
52c009a2ec [AST] Improve JSON representation of various AST nodes. 2025-01-22 14:26:13 -05:00
Tony Allevato
a57fb4dfa9 [AST] Add minimal JSON support to ASTDumper.
This only takes the existing AST information and writes it as JSON
instead of S-expressions. Since many of these fields are stringified,
they're not ideal for the kind of analysis clients of the JSON format
would want to do. A future commit will update these values to use a
more structured representation.
2025-01-22 14:26:13 -05:00
Tony Allevato
d14f3c94fd [AST] NFC: Refactor format-specific printing into a "writer".
This makes the low-level `print*` methods in `PrintBase` simply
forward to the writer, which does the actual work. Right now,
there's only the abstract base class for the writer and the
default (S-expression-like) writer. A later commit will
introduce the JSON writer.

Also update the `printField*` methods to take `Label`s instead
of `StringRef`s.
2025-01-22 14:26:13 -05:00
Tony Allevato
80f713b489 [AST] NFC-ish: Improve printing of availability specs.
Availability specs are currently dumped by writing a pre-formatted
string directly to the output stream instead of using the structured
primitives in `PrintBase`. This needs to be fixed before we can
introduce the generalized writers.

The format here is meant to be the same as the format printed by
the original methods, but some colors may differ slightly when
dumping to the terminal.
2025-01-22 14:23:32 -05:00
Tony Allevato
8670ecf245 [AST] NFC: Refactor ASTDumper to use a "label" abstraction.
ASTDumper allows nodes/values to be printed without labels, which
works fine for the default output but won't work for JSON when every
value needs to have a valid key. To balance these needs, we create
a `Label` abstraction that can be created as either `always` or
`optional`. All the current labels are treated as `always`, and all
other values have had `optional` labels associated with them, which
won't be printed in the default AST dump.

This change also adds a `printList` function that replaces anywhere
that `for` loops with `printRec` calls in their bodies. This will
be used to provide the necessary array structuring for JSON output
later. (There are some places where `for` loops call `printFlag`
which will need to be dealt with later.)
2025-01-22 14:23:32 -05:00
Allan Shortlidge
52b89a8ee0 Merge pull request #78805 from tshortli/private-available-attr-fields
AST: Eliminate remaining direct access to AvailableAttr's fields
2025-01-22 03:41:30 -08:00
Becca Royal-Gordon
ebea19d7b9 Merge pull request #78697 from beccadax/rdar142693093
Work around Foundation NS_TYPED_ENUM bug
2025-01-22 00:57:41 -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
Pavel Yaskevich
ca96a2b060 [AST] Define @execution(concurrent | caller) attribute on function declarations 2025-01-17 15:40:00 -08:00
Becca Royal-Gordon
992d9af8b7 [NFC] Indicate whether dumped types are imported 2025-01-16 15:33:58 -08:00
Alejandro Alonso
09d122af7c Merge pull request #76438 from Azoy/vector
[stdlib] Slab
2025-01-12 10:36:25 -08:00
Allan Shortlidge
393ad9872a Merge pull request #78541 from tshortli/available-attr-remodel
AST: Refactor `AvailableAttr` representation to use `AvailabilityDomain`
2025-01-11 02:39:27 -08:00
Allan Shortlidge
51aaacceb7 AST: Remove AvailableAttr::getPlatformAgnosticAvailability(). 2025-01-10 19:18:42 -08:00
Allan Shortlidge
8cd9319a3e AST: Improve ASTDumper output for AvailableAttr.
The platform field now indicates whether the attribute applies universally, to
a specific platform, to the Swift language, or to package descriptions.
Additionally the output now reflects whether or not the attribute specifies
unconditional deprecation or unavailabity or is `noasync`.
2025-01-10 18:43:12 -08:00