Commit Graph

779 Commits

Author SHA1 Message Date
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Alex Hoppen
ff0f1a47cb [ASTGen] Parse Swift version to SwiftParser 2024-02-23 11:35:58 -08:00
Slava Pestov
1c24b880ec Merge pull request #70467 from AnthonyLatsis/recursive-member-typerepr
AST: Remodel `MemberTypeRepr` to be recursive
2024-02-16 11:36:31 -05:00
Konrad `ktoso` Malawski
e9c7f3c382 [Distributed] Target identifiers for protocol calls (#70928) 2024-02-16 07:19:20 -08:00
Rintaro Ishizaki
1105309cdc Merge pull request #71631 from rintaro/astgen-trailingclosure
[ASTGen] Generate trailing closures
2024-02-15 19:03:21 -08:00
Rintaro Ishizaki
c8be142bbb [ASTGen] Generate traling closures
Bridge ArgumentList instead of using temporary TupleExpr.
2024-02-15 13:02:15 -08:00
Michael Gottesman
23ab974574 Merge pull request #71567 from gottesmm/transferring-param
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
2024-02-14 17:54:48 -08:00
Doug Gregor
8000ef32fa Merge pull request #71619 from DougGregor/swift-diags-performance
Improve performance of bridge to the new diagnostics formatter
2024-02-14 16:56:54 -08:00
Doug Gregor
81ffafdc6a Merge pull request #70602 from ApolloZhu/macro/expression-as-default-argument
[Macros] Expression macro as caller-side default argument
2024-02-14 16:10:11 -08:00
Michael Gottesman
bf2ec7eb85 [transferring] Change transferring to no longer be a ParamSpecifier.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.

NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.

rdar://121324715
2024-02-14 13:04:46 -08:00
Doug Gregor
f3ff1b4dee Provide the cached SourceLocationConverter for emitted diagnostics 2024-02-14 11:25:22 -08:00
Joe Groff
72486c975f Merge pull request #71472 from jckarter/borrowing-switch-7
Pass on the `BorrowingSwitch` feature flag to the SwiftSyntax parser.
2024-02-12 13:18:28 -08:00
Anthony Latsis
de499d1060 [NFC] ASTGen: Refactor for recursive MemberTypeRepr representation 2024-02-09 17:23:40 +03:00
Joe Groff
f832ba220a Pass on the BorrowingSwitch feature flag to the SwiftSyntax parser.
And remove the `-disable-experimental-parser-round-trip` flag from borrowing
switch tests now that the SwiftSyntax parser supports them with
https://github.com/apple/swift-syntax/pull/2487.
2024-02-08 10:06:48 -08:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Apollo Zhu
4818670d48 Update with Swift Syntax 2024-02-06 15:02:15 -08:00
Apollo Zhu
ea35e1bac2 Use Swift Syntax for checking literals 2024-02-06 15:02:15 -08:00
Konrad `ktoso` Malawski
5acd366c98 [macros] allow forwarding generic arguments through macro declarations (#71271)
* [macros] allow forwarding generic arguments through macro declarations

[macros] add more tests for generic argument forwarding in macro declarations

* [macros] correct replacement picking logic
2024-02-06 03:56:20 -08:00
Hamish Knight
c9fcab1e70 Merge pull request #71389 from hamishknight/all
[ASTGen] NFC: Use `allSatisfy` instead of `all`
2024-02-05 19:21:04 +00:00
Doug Gregor
b5632dece2 Merge pull request #71362 from DougGregor/parent-context-of-macro 2024-02-05 06:31:59 -08:00
Hamish Knight
6052fd9545 [ASTGen] NFC: Use allSatisfy instead of all 2024-02-05 14:14:22 +00:00
John McCall
dd90ae7416 Rename SIL's @isolated attribute to @sil_isolated.
We want to use @isolated in ordinary Swift, and while we could probably
make it coexist with this SIL use, doing so would be really inconvenient.
2024-02-03 01:51:36 -05:00
Doug Gregor
e7be8f32f1 Provide the lexical context to macro expansions 2024-02-02 16:03:29 -08:00
Rintaro Ishizaki
b12370a7ca Merge pull request #71342 from rintaro/ast-attrkind 2024-02-02 13:16:14 -08:00
Allan Shortlidge
002277d2c3 ASTGen: Suppress warnings about handling unknown enum cases.
When built as part of the compiler toolchain SwiftSyntax is built with library
evolution enabled. This means that switches over enums from SwiftSyntax must
include a default case to be considered exhaustive, or a warning will be
emitted. This change suppresses those warnings by adding `@unknown default`
cases wherever they are expected. As a compromise, these `@unknown default`
cases are wrapped with a `#if` to ensure they are only included in the CMake
build of ASTGen, but continue to be omitted from the SPM build which compiler
engineers use to iterate on ASTGen's implementation. This is needed to avoid
generating the opposite warning during the SPM build, since the compiler thinks
the `@unknown default` case is superfluous when SwiftSyntax is built
non-resiliently. As an aside, this catch-22 is a bummer and I think we should
change the compiler to suppress the unreachable default warning when the
default is annotated `@unknown`.
2024-02-02 09:42:10 -08:00
Rintaro Ishizaki
07bb0380a1 [AST] Use class names for type attribute kind enum
Align with DeclAttrKind.
2024-02-02 09:36:47 -08:00
Rintaro Ishizaki
6f4abe7484 Merge pull request #71321 from rintaro/astgen-typeattr
[ASTGen] Cleanup type attribute generation
2024-02-01 23:01:16 -08:00
Allan Shortlidge
93c9474b20 NFC: Resolve "was never used" warnings in ASTGen. 2024-02-01 18:34:45 -08:00
Allan Shortlidge
5ee9bfda7b NFC: Resolve "was never mutated" warnings in ASTGen. 2024-02-01 18:32:37 -08:00
Allan Shortlidge
8e00de06cb NFC: Address deprecation warnings in ASTGen. 2024-02-01 18:30:52 -08:00
Rintaro Ishizaki
cd7a31cddc [ASTGen] Cleanup type attribute generation
Use similar scheme as DeclAttribute.
* Create `BridgedTypeAttribute.createSimple()` and
  `BridgedTypeAttributes.add()`, instead of
  `BridgedTypeAttributes.addSimple()`
* Create `DeclAttributes::createSimple()` to align with `TypeAttribute`
2024-02-01 15:45:50 -08:00
Rintaro Ishizaki
a0120ad884 [ASTGen] Decl attributes 2024-01-31 12:58:41 -08:00
pinkjuice66
31054398cb [SwiftSyntax] Reflects the API changes in swift-syntax 2024-01-29 19:33:36 +09:00
John McCall
41cdfb04ad Introduce a proper TypeAttribute class hierarchy.
The old TypeAttributes reprsentation wasn't too bad for a small number of
simple attributes.  Unfortunately, the number of attributes has grown over
the years by quite a bit, which makes TypeAttributes fairly bulky even at
just a single SourceLoc per attribute.  The bigger problem is that we want
to carry more information than that on some of these attributes, which is
all super ad hoc and awkward.  And given that we want to do some things
for each attribute we see, like diagnosing unapplied attributes, the linear
data structure does require a fair amount of extra work.

I switched around the checking logic quite a bit in order to try to fit in
with the new representation better.  The most significant change here is the
change to how we handle implicit noescape, where now we're passing the
escaping attribute's presence down in the context instead of resetting the
context anytime we see any attributes at all.  This should be cleaner overall.

The source range changes around some of the @escaping checking is really a
sort of bugfix --- the existing code was really jumping from the @ sign
all the way past the autoclosure keyword in a way that I'm not sure always
works and is definitely a little unintentional-feeling.

I tried to make the parser logic more consistent around recognizing these
parameter specifiers; it seems better now, at least.
2024-01-28 22:30:26 -05:00
Michael Gottesman
6f3d45219a [ast] Represent a parameter's isolation at the SIL level.
I did this by adding flag on SILParamInfo.

rdar://121387872
2024-01-23 15:20:22 -08:00
Pavel Yaskevich
6cdab78028 Merge pull request #70867 from xedin/dynamic-enforcement-of-witness-isolation-with-preconcurrency
[TypeChecker/SILGen] Dynamic enforcement of witness/objc isolation with @preconcurrency attribute
2024-01-17 10:01:37 -08:00
Doug Gregor
255009dddb Implement #isolation macro to produce the isolation of the current context
Introduce a new expression macro that produces an value of type
`(any AnyActor)?` that describes the current actor isolation. This
isolation will be `nil` in non-isolated code, and refer to either the
actor instance of shared global actor in other cases.

This is currently behind the experimental feature flag
OptionalIsolatedParameters.
2024-01-16 14:25:51 -08:00
Pavel Yaskevich
574aee0113 [AST] Allow @preconcurrency attribute in inheritance clause 2024-01-16 10:29:47 -08:00
Ben Barham
a159604f1c Merge pull request #70415 from ahoppen/ahoppen/cache-source-loc-converter
[Macros] Cache `SourceLocationConverter` in `ExportedSourceFile`
2024-01-08 10:49:38 -08:00
Doug Gregor
baaa8f3e5b Merge pull request #70677 from DougGregor/se-0413-typed-throws
Enable SE-0413 "Typed Throws" by default
2024-01-04 16:11:26 -08:00
Doug Gregor
b9c5aca15f Enable SE-0413 "Typed Throws" by default 2024-01-02 15:34:07 -08:00
Michael Gottesman
abba624f6e Add an experimental option TransferringArgsAndResults.
Just splitting off a larger commit to make this easier to review.
2024-01-02 15:03:05 -08:00
Rintaro Ishizaki
409b2760f9 [ASTGen] Statements 2023-12-18 16:09:25 -08:00
Hamish Knight
0a35e00002 [ASTGen] Be defensive over nil firstName
If we only have one name, it should be in
`firstName`, but if it's in `secondName`, handle it
the same, since that's syntactically the same thing.
2023-12-15 21:46:21 +00:00
Hamish Knight
6ebfb60b2c [ASTGen] Diagnose unknown accessor specifiers 2023-12-15 21:46:21 +00:00
Hamish Knight
f9730a7f40 [ASTGen] Generate SubscriptDecls 2023-12-15 21:44:31 +00:00
Hamish Knight
9710a6575d [ASTGen] Better handle ParamDecl arg/param name generation
Move the logic onto the ASTGen side, and plumb
through the flag that will allow subscripts
to have a different argument name defaulting
behavior.
2023-12-15 21:44:30 +00:00
Hamish Knight
29bfdac299 [ASTGen] Generate AccessorDecls 2023-12-15 21:44:30 +00:00
Hamish Knight
28cfe4b7db [ASTGen] Generate type annotations for bindings
Handle the wrapping of TypedPatterns when a type
annotation is specified, and the implicit wrapping
behavior for previously written NamedPatterns.
2023-12-15 21:44:30 +00:00