Commit Graph

779 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
0c111ace0a [ASTGen] Implement SequenceExpr generation 2023-12-04 06:50:31 -08:00
Hamish Knight
f4e09c5531 [AST] Tighten up invariants around IfStmt
The 'then' statement must be a BraceStmt, and
the 'else' must either be a BraceStmt or an IfStmt.
2023-12-04 11:09:01 +00:00
Rintaro Ishizaki
d592ae4d9c [ASTGen] Generalize BridgedNullable
Declare `BridgedNullable` protocol for `ExpressibleByNilLiteral`.
Simplify `HasNullable` implementation using `BridgedNullable`, and
rename it to `BridgedHasNullable`.
2023-12-03 22:52:46 -08:00
Doug Gregor
c7c2f054c8 Merge pull request #70169 from DougGregor/throws-clause
Adjust for throws-clause refactoring in swift-syntax
2023-12-02 07:32:21 -08:00
Doug Gregor
5aa29c0b1d Adjust for throws-clause refactoring in swift-syntax 2023-12-01 12:47:46 -08:00
Rintaro Ishizaki
c46eb58ed8 Merge pull request #70138 from rintaro/astgen-compoundname
[ASTGen] Generate compound name expression
2023-12-01 11:31:38 -08:00
Rintaro Ishizaki
4796ea458a [ASTGen] Generate compound name expression
Bridge DeclBaseName, DeclNameRef, and DeclNameLoc.
Implement UnresolvedMemberExpr generation.
2023-11-30 14:42:02 -08:00
Alex Hoppen
cc858ab253 Merge pull request #70008 from ahoppen/ahoppen/name-matcher-in-swift
Share implementation of local rename and related identifiers + implement `NameMatcher` in Swift
2023-11-30 09:37:53 -08:00
Alex Hoppen
bc5cc43a06 Don’t include <vector> in IDEBridging.h 2023-11-28 14:04:37 -08:00
Alex Hoppen
14bc8148fe Don’t include vector in `BasicBridging.h 2023-11-28 14:03:31 -08:00
Alex Hoppen
b31398215d Don’t include SourceLoc.h when USED_IN_CPP_SOURCE is not set 2023-11-27 19:34:27 -08:00
Doug Gregor
36a2dcd927 Implement function body macros
Function body macros allow one to introduce a function body for a
particular function, either providing a body for a function that
doesn't have one, or wholesale replacing the body of a function that
was written with a new one.
2023-11-27 17:04:55 -08:00
Alex Hoppen
f408619ddc Address Hamish’s review comments 2023-11-27 14:17:04 -08:00
Alex Hoppen
fc08a24e95 [build] Set CRT_USE_BUILTIN_OFFSETOF when building with C++ interop on Windows
Without this, header fail to compile when they are used from Swift with C++ interop.
2023-11-22 21:36:55 -08:00
Alex Hoppen
330ed60401 [SourceKit] Don't use C++ interop to append elements to a ResolvedLocVector
This was causing build issues on Linux with Swift 5.8. Instead, wrap the `std::vector` in a `BridgedResolvedLocVector` that has a pointer to a heap-allocated `std::vector`
2023-11-22 16:41:07 -08:00
Alex Hoppen
d224549030 [SourceKit] Don’t use C++ to Swift interop to run NameMatcher 2023-11-20 11:30:18 -08:00
Alex Hoppen
8fd025625b [SourceKit] Use NameMatcher that is rewritten in Swift for syntactic rename 2023-11-17 09:30:04 -08:00
Rintaro Ishizaki
e395df3ef3 Merge pull request #69930 from rintaro/astgen-regex-cleanup
[Parse] Remove RegexParserBridging.h
2023-11-16 19:04:24 -08:00
Rintaro Ishizaki
49f28c8651 Merge pull request #69894 from rintaro/astgen-choice-optional
[ASTGen] Several improvements to generalize node handling
2023-11-16 16:25:54 -08:00
Rintaro Ishizaki
986415a4af [Parse] Remove RegexParserBridging.h
This is not used anymore
2023-11-16 14:01:41 -08:00
Rintaro Ishizaki
24b44e371c Revert "ASTGen: add a workaround for CSC conformance visibility"
This reverts commit 5d0c5a643f.
2023-11-16 11:02:52 -08:00
Rintaro Ishizaki
47f18d492e [ASTGen] Move regex literal parsing from SwiftCompilerSources to ASTGen
ASTGen always builds with the host Swift compiler, without requiring
bootstrapping, and is enabled in more places. Move the regex literal
parsing logic there so it is enabled in more host environments, and
makes use of CMake's Swift support. Enable all of the regex literal
tests when ASTGen is built, to ensure everything is working.

Remove the "AST" and "Parse" Swift modules from SwiftCompilerSources,
because they are no longer needed.
2023-11-16 10:59:23 -08:00
Rintaro Ishizaki
aeb7a215fd [ASTGen] Add back specialized generate() functions for optional nodes 2023-11-15 13:43:20 -08:00
Rintaro Ishizaki
db4a2a4e02 [ASTGen] Generalize Optional node handling
Defining `generate(_: XXXSyntax?) -> BridgedXXX` for each node kind is too
much boilerplate.

  self.generate(optional: optionalXXXNode).asNullable

is now:

  self.map(optionalXXXNode, generate(xxx:))
2023-11-15 11:04:12 -08:00