Commit Graph

803 Commits

Author SHA1 Message Date
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
Rintaro Ishizaki
91fa051a37 [ASTGen] Remove TypeRepr from ASTGen.ASTNode
Now that ASTNode is used only for codeBlockItem generation. That align
with C++ ASTNode where it represent code items.

Since TypeRepr is not an ASTGen in C++, remove it from ASTGen too.
2023-11-15 10:59:10 -08:00
Rintaro Ishizaki
d95d7e526e [ASTGen] Generate ConditionElement using switch
Generating ConditionElement using generate(_:) wouldn't work when we
implemnt other condition kinds e.g. patterns because they are not
ASTNode kinds.
Remove generate(choices:) and generate(_:) as they weren't used anymore.
2023-11-15 10:59:10 -08:00
Rintaro Ishizaki
1d558ebe52 [ASTGen] Don't use generate(_: Syntax) -> ASTNode for partial gen
We already know the type of the node. There's no reason switch over
again and wrap the result with ASTNode.
2023-11-15 10:59:10 -08:00
Rintaro Ishizaki
94c6987c97 [ASTGen] Reduce usage of generate(choices:)
`generate(choices:)` is not good because it expects "ASTNode". Not all
`SyntaxChildChoices` can generate ASTNode.

* `generate(codeBlockItem:)` to manually switch over the cases
* switch on `IfExpr.ElseBody` insdie `makeIfStmt()`, now supports `else
  if` case
2023-11-15 10:59:08 -08:00
Rintaro Ishizaki
07a432d2a5 [ASTGen] Soft deprecate generate(choices:) 2023-11-14 19:49:10 -08:00
Rintaro Ishizaki
5fdeabd045 [ASTGen] Give argument labels to all generate(_:) functions
Explicit argument labels are useful for "Open Quickly..." in Xcode,
reduce the fear of miss overload resolution, and better crash
backtrace as they might not show parameter types.
2023-11-14 19:49:10 -08:00
Rintaro Ishizaki
215abe6d40 [ASTGen] Start generating Patterns 2023-11-14 10:47:31 -08:00
Rintaro Ishizaki
038597c80f [ASTGen] Use kind specific SyntaxEnum 2023-11-14 10:47:16 -08:00
Rintaro Ishizaki
b3991732c7 Merge pull request #69761 from rintaro/astgen-incremental-develop
[ASTGen] Infrastructure for implementing ASTGen incrementally
2023-11-13 14:10:28 -08:00
Rintaro Ishizaki
f3f4b19776 [ASTGen] Remove ASTGenTypes experimental feature
There's no reason to generate only TypeRepr using ASTGen anymore.
Use ParserASTGen feature to test test/ASTGen/types.swift because
ASTGen now can generate the whole test file for type checking.
2023-11-12 21:43:09 -08:00
Rintaro Ishizaki
fb08a92f48 [ASTGen] Infrastructure to implment ASTGen Incrementally
* 'ASTGenVisitor' has a reference to a legacy C++ Parser configured for
  ASTGen.
* If 'ASTGenVisitor' encounters a AST node that hasn't been migrated,
  call parse(Decl|Stmt|Expr|Type) to parse the position using the legacy
  parser.
* The legacy parser calls ASTGen's
  'swift_ASTGen_build(Decl|Stmt|Expr|Type)' for each ASTNode "parsing"
  (unless the call is not directly from the ASTGen.)

rdar://117151886
2023-11-12 21:43:08 -08:00
Sophia Poirier
353d04fd73 Merge pull request #69725 from sophiapoirier/nonisolated-unsafe-experimental-feature-flag-mapping
map nonisolated(unsafe) experimental feature for SwiftParser
2023-11-10 19:30:52 -08:00
Rintaro Ishizaki
2c8d7f2550 [ASTGen] Generalize findSyntaxNodeInSourceFile(wantOutermost:true)
When 'wantOutermost' is true, traverse the parent as long as the
position is the same as the target position.
2023-11-10 12:59:19 -08:00
Rintaro Ishizaki
da9813e517 [ASTGen] Add copyright headers 2023-11-09 23:33:01 -08:00
Sophia Poirier
6690d57465 map nonisolated(unsafe) experimental feature for SwiftParser 2023-11-09 11:05:34 -08:00
Alejandro Alonso
16cbb76fc6 Merge pull request #69710 from Azoy/stdlib-warning-cleanup
[stdlib] Silence some standard library warnings
2023-11-08 20:09:13 -08:00
Alejandro Alonso
e41fe5a173 Special case some unknown builtin macros 2023-11-08 16:02:31 -08:00
Meghana Gupta
5658deae27 Add initial support for _resultDependsOnSelf
This is used to establish lifetime dependence between self and the result.

Add under NonEscapableTypes experimental feature
2023-11-08 01:48:59 -08:00
Hamish Knight
32ee2ccf68 [ASTGen] Build with -disable-target-os-checking
Temporarily workaround an availability issue with
CxxStdlib.
2023-11-01 17:39:55 +00:00
Hamish Knight
e19954f981 Merge pull request #69534 from hamishknight/bridgnt 2023-10-31 22:08:53 +00:00
Saleem Abdulrasool
8354c864b0 build: guard against builds where SwiftSyntax may not be enabled
Fix the build after #69440
2023-10-31 07:53:12 -07:00
Hamish Knight
9216672db7 Improve some bridging interfaces
Migrate a bunch of structs to classes, and
uppercase field names.
2023-10-31 11:06:41 +00:00
Hamish Knight
3cb74e911b Address review feedback 2023-10-30 23:50:01 +00:00
Hamish Knight
2a6d93f505 [Basic] Improve API of BridgedArrayRef + BridgedData
Remove the default constructor footgun present with
the struct implementations, and sprinkle some
`SWIFT_NAME` and bridging utilities to make them
nicer to work with.
2023-10-30 23:49:59 +00:00
Hamish Knight
dc899c53de [AST] Use consistent naming for bridging functions
Add a `Bridged` prefix to match the name being
exposed to Swift, and to match the other bridging
functions. Also while here, use `SWIFT_NAME` for
some bridging functions that were missing it.
2023-10-30 23:49:58 +00:00
Hamish Knight
6afde8a6d2 Remove CBasicBridging and CASTBridging
Merge with BasicBridging and ASTBridging
respectively. The changes here should be pretty
uncontroversial, I tried to keep it to just moving
code about.
2023-10-30 23:49:56 +00:00