Commit Graph

803 Commits

Author SHA1 Message Date
Adrian Prantl
40f8cfd5a8 Prefix experimental interop flag with -Xfrontend 2024-04-17 12:51:07 -07:00
Rintaro Ishizaki
895ac3ef96 Merge pull request #71513 from rintaro/astgen-pluginmessage-spi 2024-04-12 18:33:23 -07:00
Rintaro Ishizaki
ae3a169338 [ASTGen] Update for SPI in swift-syntax
All symbols in `SwiftCompilerPluginMessageHandling` are now SPI.
2024-04-12 12:08:00 -07:00
Erik Eckstein
a980452e59 Add the experimental attribute @sensitive for struct declarations
The attribute declares that a struct contains "sensitive" data.
It enforces that the contents of such a struct value is zeroed out at the end of its lifetime.
In other words: the content of such a value is not observable in memory after the value's lifetime.

Also add an experimental feature `Sensitive` with which the attribute can be enabled.
2024-04-09 12:01:10 +02:00
Rintaro Ishizaki
9d336a072e [ASTGen/Macros] Ensure 'offset' from plugin response is valid
We see some crashes presumably caused by invalid 'offset' returned from
macro plugins. Although we haven't been able to find a reproducer, guard
not to generate invalid source location by checking 'offfset' is within
the buffer length.

rdar://125625879
2024-03-29 15:16:47 -07:00
Becca Royal-Gordon
05e93da398 Simplify and test ASTGen support
Rather than adding custom parsing to SwiftSyntax, we can parse this as a custom attribute and convert it to a built-in one in ASTGen. Test that this works correctly (and fix a bug where it wasn’t).
2024-03-28 15:48:15 -07:00
Becca Royal-Gordon
8fc46fece8 [NFC] Add flag distinguishing @impl and @objcImpl
They will have slightly different enablement and diagnostic behavior in a future commit.
2024-03-27 14:29:56 -07:00
Allan Shortlidge
1e4549961c Merge pull request #72604 from tshortli/disallow-feature-suppression-attr
AST: Introduce `@_disallowFeatureSuppression` attribute
2024-03-26 21:57:58 -07:00
Allan Shortlidge
b249503a2b AST: Introduce @_disallowFeatureSuppression attribute.
This attribute is the inverse of the existing `@_allowFeatureSuppression`
attribute.

Part of rdar://125138945
2024-03-26 17:27:57 -07:00
Alex Hoppen
29cd75ccba [ASTGen] Adjustments for the deprecation of CanImportExpr and CanImportVersionInfo 2024-03-25 17:55:56 +01:00
Rintaro Ishizaki
58e70e8535 Merge pull request #72103 from rintaro/astgen-stringliteral
[ASTGen] Generate interpolated string literal
2024-03-13 10:08:15 +09:00
Konrad `ktoso` Malawski
8854438d87 [Distributed] Remove _distributedThunkTarget; it is not necessary (#72245) 2024-03-11 20:48:05 -07:00
Rintaro Ishizaki
e5592c7984 [ASTGen] Generate interpolated string literal 2024-03-06 10:32:00 -08:00
Anthony Latsis
fd93eea16b Merge pull request #70608 from AnthonyLatsis/unqualified-ident
[NFC] AST: Merge `SimpleIdentTypeRepr` & `GenericIdentTypeRepr` into `IdentTypeRepr`
2024-03-06 09:41:16 +03:00
Kavon Farvardin
215bd3cab4 Mangling: handle inverse requirements 2024-03-05 14:19:00 -08:00
Allan Shortlidge
70f42027ae Merge pull request #72026 from tshortli/resolve-astgen-warnings 2024-03-02 09:38:40 -08:00
Anthony Latsis
7e7f6d8d61 [NFC] AST: Construct SimpleIdentTypeRepr & GenericIdentTypeRepr through IdentTypeRepr 2024-03-02 08:28:47 +03:00
John McCall
1437acdf22 Implement conditional feature suppression.
Our standard conception of suppressible features assumes we should
always suppress the feature if the compiler doesn't support it.
This presumes that there's no harm in suppressing the feature, and
that's a fine assumption for features that are just adding information
or suppressing new diagnostics.  Features that are semantically
relevant, maybe even ABI-breaking, are not a good fit for this,
and so instead of reprinting the decl with the feature suppressed,
we just have to hide the decl entirely.  The missing middle here
is that it's sometimes useful to be able to adopt a type change
to an existing declaration, and we'd like older compilers to be
able to use the older version of the declaration.  Making a type
change this way is, of course, only really acceptable for
@_alwaysEmitIntoClient declarations; but those represent quite a
few declarations that we'd like to be able to refine the types of.

Rather than trying to come up with heuristics based on
@_alwaysEmitIntoClient or other sources of information, this design
just requires the declaration to opt in with a new attribute,
@_allowFeatureSuppress.  When a declaration opts in to suppression
for a conditionally-suppressible feature, the printer uses the
suppression serially-print-with-downgraded-options approach;
otherwise it uses the print-only-if-feature-is-available approach.
2024-03-01 22:10:14 -05:00
Allan Shortlidge
a337eaadf9 ASTGen: Resolve a 'may have additional unknown values' warning. 2024-03-01 17:11:09 -08:00
Allan Shortlidge
1a5a721019 ASTGen: Resolve 'was never mutated' warnings. 2024-03-01 17:01:10 -08:00
Allan Shortlidge
d10f6f9013 ASTGen: Resolve 'was defined but never used' warnings. 2024-03-01 17:01:10 -08:00
Allan Shortlidge
7c1cdaf49b ASTGen: Resolve 'may have additional unknown values' warnings. 2024-03-01 17:01:10 -08:00
Doug Gregor
6075de1b62 Add upcoming feature ImplicitOpenExistentials for SE-0352
To maintain source compatibility, SE-0352 does not open existentials
with "self-conforming" type, such as `any Error` or existentials based
on `@objc` protocols. The proposal specified that this behavior would
change in Swift 6. Implement that behavior change, which can be
enabled prior to Swift 6 with the upcoming feature
`ImplicitOpenExistentials` (as documented in SE-0362).

Fixes #70873 / rdar://120902975.
2024-03-01 11:50:39 -08:00
Doug Gregor
d1ac903be4 Introduce a suppressible feature for availability on associated types
This allows us to emit Swift interfaces that can be handled by older
Swift compilers.
2024-02-29 10:09:08 -08:00
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