Commit Graph

803 Commits

Author SHA1 Message Date
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
Hamish Knight
b04d5d5abc [ASTGen] Better handle pattern binding entries
Generate all entries, and ensure we introduce a
PatternBindingInitializer context for non-local
cases. Also use this opportunity to cleanup
`PatternBindingDecl::create`.
2023-12-15 21:44:30 +00:00
Hamish Knight
ab9b3ffa7b [ASTGen] NFC: Run swift-format 2023-12-15 21:44:30 +00:00
Andrew Trick
ace9937e95 Rename NonesapableTypes feature
Follow the feature flag convention for capitalization and be
consistent with the related NoncopyableGenerics feature.

This is a new feature that no wild Swift code has used it yet:

commit e99ce1cc5d
Author: Kavon Farvardin <kfarvardin@apple.com>
Date:   Tue Dec 5 23:25:09 2023

    [NCGenerics] add `~Escapable`

    Basic implementation of `~Escapable` in the type system.
2023-12-14 11:32:03 -08:00
Sophia Poirier
55f9057e61 Merge pull request #70453 from sophiapoirier/unguard-nonisolated-unsafe-feature
[Concurrency] unguard nonisolated(unsafe) attribute from GlobalConcurrency experimental feature
2023-12-14 08:29:21 -08:00
Alex Hoppen
8da07543da [Macros] Cache SourceLocationConverter in ExportedSourceFile
We need a `SourceLocationConverter` every time we create a `PluginMessage.Syntax` to know the source location of that syntax node within the source file. This means that we needed to re-build the line table of the entire source file multiple times for every macro that we expand. Cache it to improve performance.

rdar://119047550
2023-12-14 08:13:48 -08:00
Sophia Poirier
d319404e16 [Concurrency] unguard nonisolated(unsafe) attribute from GlobalConcurrency experimental feature 2023-12-13 15:06:07 -08:00
Rintaro Ishizaki
eb46b6f352 [ASTGen] Implement patterns
Except `MissingPatternSyntax`
2023-12-11 14:00:40 -08:00
Rintaro Ishizaki
847a5671e6 [ASTGen] BridgedXXXTypeRepr_createParsed return the sub type if possible
Just for the consistensy with other BridgedXXX_createParsed().
2023-12-08 15:07:58 -08:00
Rintaro Ishizaki
8f70dc3535 [ASTGen] Implement PackElementTypeRepr, InverseTypeRepr and class constraint 2023-12-08 12:15:16 -08:00
Rintaro Ishizaki
5e271ec4ee [ASTGen] Implement PackElement and PackExpansion expressions 2023-12-08 12:15:05 -08:00
Rintaro Ishizaki
0084a8a834 [ASTGen] Implement unary expressions
AwaitExpr, BorrowExpr, ConsumeExpr, CopyExpr, TryExpr, ForceTryExpr,
and OptionalTryExpr.
2023-12-08 12:15:05 -08:00
Rintaro Ishizaki
471cba2eca [ASTGen] Implement dictionary literal expression generation 2023-12-08 12:15:04 -08:00
Rintaro Ishizaki
8b026f2334 [ASTGen] Implement DotSelfExpr generation 2023-12-08 12:12:16 -08:00
Rintaro Ishizaki
a12113a490 [ASTGen] TokenSyntax.keyworkKind to directly get Keyword kind
This should be faster than e.g. `token.tokenKind == .keyword(.true)`.
2023-12-07 00:23:51 -08:00
Meghana Gupta
9a4bb7337a Merge pull request #70263 from meg-gupta/resultdependson
Add support for _resultDependsOn
2023-12-06 22:12:23 -08:00
Alex Hoppen
222739a71d Merge pull request #70255 from ahoppen/ahoppen/rename-refactoring
[Rename] Collection of improvements to make syntactic rename easier to read
2023-12-06 19:46:01 -08:00
Meghana Gupta
b6326f5f24 Add initial support for _resultDependsOn
These attributes are used to establish lifetime dependence between
argument and the result.

Add them under NonEscapableTypes experimental feature
2023-12-06 16:38:38 -08:00
Alex Hoppen
5cae50a1a6 [SourceKit] Refactor addSyntacticRenameRanges
Refactor `addSyntacticRenameRanges`, adding comments to make it easier to follow and remove its dependency on the `IsFunctionLike` parameter in `RenameLoc`.
2023-12-06 14:31:47 -08:00
Ben Barham
cb29ec8837 [CMake] Ignore None and NoneType deprecations
`llvm::None` is deprecated, but still being used in Swift until we have
fewer 5.10 cherry-picks. Add the `SWIFT_TARGET` definition to ignore the
deprecation.
2023-12-06 10:47:02 -08:00
Rintaro Ishizaki
813f1d8fa8 [ASTGen] Small cleanups
* Remove 'public' from the functions, those werr remnants of when
  ASTGenVisitor conformed to SyntaxTransformVisitor.
* Remove an unreachable `default:` from a switch.
* Remove unused `UnsafePointer.raw`.
2023-12-05 19:29:50 -08:00
Rintaro Ishizaki
2f46e6f311 [ASTGen] Add back TokenSyntax.bridgedIdentifier(in:) etc.
To avoid conflicts while migration. When all usage are migrated, this
commit should be reverted.
2023-12-05 14:32:14 -08:00
Rintaro Ishizaki
7ab4003a96 [ASTGen] Move getIdentifier() etc to ASTGenVisitor
Now that `getIdentifier()` has some logic in it. It's not a simple
bridging.
2023-12-05 14:32:09 -08:00
Rintaro Ishizaki
71ecdfca3f [ASTGen] Move getIdentifier logic to ASTGen side
Ideally ASTBriding should only do the neccessary work for briding. All
non-trivial logic should be in ASTGen.
2023-12-05 14:26:31 -08:00
Rintaro Ishizaki
e1f0089873 [ASTGen] Start using 'TokenSyntax.rawText'
`TokenSyntax.text` causes intiation of heap allocated `Swift.String` for
each access. `TokenSyntax.rawText` is faster than that because it's just
a reference to the pre-allocated buffer. Also, converting to
`BridgedString` is simplar, and guaranteed to be free, unlike bridging
via `String.withUTF8(_:)`
2023-12-04 14:00:39 -08:00
Rintaro Ishizaki
a7a0b329f2 Merge pull request #70168 from rintaro/astgen-sequenceexpr
[ASTGen] Implement SequenceExpr generation
2023-12-04 11:31:36 -08:00
Hamish Knight
e6ec9b0c8b Merge pull request #70172 from hamishknight/or-else 2023-12-04 17:33:57 +00:00