Commit Graph

779 Commits

Author SHA1 Message Date
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
Hamish Knight
fce1cb54d5 [AST] Merge BridgedDiagnosticEngine + BridgedDiagEngine
Introduce a macro that can stamp out wrapper
classes for underlying C++ pointers, and use
it to define BridgedDiagnosticEngine in
ASTBridging. Then, migrate users of
BridgedDiagEngine onto it.
2023-10-30 23:49:55 +00:00
Hamish Knight
fe0ad60fe8 [ASTGen] Fix a couple of @_cdecl param types
These are `void *` on the C side.
2023-10-30 23:49:54 +00:00
Hamish Knight
356cf31d83 [ASTGen] Migrate onto some BasicBridging types
Migrate onto BridgedStringRef, and the
BasicBridging equivalents of BridgedSourceLoc
and BridgedArrayRef.
2023-10-30 23:49:53 +00:00
Hamish Knight
e5442fea50 [ASTGen] Enable C++ interop 2023-10-30 23:49:52 +00:00
Hamish Knight
d1fa767c84 Merge pull request #69326 from hamishknight/null-and-void 2023-10-23 23:54:50 +01:00
Hamish Knight
9da66906d5 [ASTGen] NFC: Fixup formatting 2023-10-23 18:41:10 +01:00
Hamish Knight
4a4a04888c [ASTGen] Introduce nullable variants of bridging wrappers
For nullable nodes, introduce both a non-null and
nullable variant of the bridging wrapper. This
allows us to annotate the necessary parameters
as nullable, but keep the returns of the bridged
`createParsed` methods non-null.
2023-10-23 18:00:13 +01:00
Hamish Knight
5d105f175d [ASTGen] NFC: Format with swift-format
This uses the same formatting configuration as
sourcekit-lsp.
2023-10-23 10:51:23 +01:00
Hamish Knight
11b8549442 Merge pull request #69229 from hamishknight/boxing-match
[ASTGen] Introduce wrapper types for AST nodes
2023-10-21 15:08:24 +01:00
Hamish Knight
3639d866cb Address review feedback 2023-10-20 22:57:14 +01:00
Hamish Knight
2ad64f1a40 [ASTGen] Use SWIFT_NAME in some more places 2023-10-20 22:57:13 +01:00
Hamish Knight
6d3c0c88a7 [ASTGen] Introduce wrapper types for AST nodes
Stamp out wrapper types for all the AST nodes,
and use them for ASTGen, with members being
imported on those types.
2023-10-20 22:57:12 +01:00
Harlan Haskins
4ac34a40ea @retroactive conformance syntax and checking (#36068) 2023-10-20 14:27:03 -07:00
Rintaro Ishizaki
bce5eeb78d [ASTGen] Null-terminate error messsages from ASTGen
Always null-terminate `BridgedString` by  `allocateBridgedString()`.
It had `nullTerminated: Bool` option, but allocating one extra byte
doesn't harm anything. Always null-terminate the string just for
client's convenience.

rdar://117205829
2023-10-19 13:29:57 -07:00
Rintaro Ishizaki
37a637447f Merge pull request #69027 from rintaro/macro-resolveerror-rdar115571427
[Macros] Improve macro plugin loading macro definition resolution diagnostics
2023-10-16 17:35:48 -07:00
Rintaro Ishizaki
444fcfabba [Macros] Tweak macro resolution error messages 2023-10-13 10:38:08 -07:00
Arnold Schwaighofer
0a5cb1e93f Merge pull request #69160 from aschwaighofer/wip_partial_sil_support_for_generic_throws
Preliminary SIL and IRGen support for error_indirect
2023-10-13 09:34:44 -07:00
Arnold Schwaighofer
9482b0c86b Preliminary SIL and IRGen support for error_indirect
IRGen lowering of non-fixed-sized typed errors and the SIL support necessary to
spell out IRGen test cases.
2023-10-12 18:09:52 -07:00
Rintaro Ishizaki
28aad9d126 [Macros] Return plugin loading error as result
Instead of emitting an warning to the diagnostic engine, return the
plugin loading error as the result of the request. So that the user
can decide to emit it as a warning or an error.
2023-10-12 16:08:54 -07:00
Rintaro Ishizaki
f8c7bd94f3 [ASTGen] Cleanup string bridging
* BridgedString for ASTGen -> C++ string returnings
* Null terminated C-strings for C++ -> ASTGen string arguments
* UnsafeMutableRawPointer for C++ -> ASTGen diagnostic engine arguments
2023-10-12 12:57:28 -07:00
Hamish Knight
042ccdda01 Merge pull request #68344 from hamishknight/do-it 2023-10-10 10:26:12 +01:00
Hamish Knight
2eb90c370a Merge pull request #68860 from ChiduAnush/changeRawSyntaxToBumpPtrAllocator 2023-10-09 20:50:42 +01:00
Hamish Knight
33f94bc874 Introduce do expressions 2023-10-06 11:17:48 +01:00
Rintaro Ishizaki
7ac5d65479 [ASTGen] Use standard headers
For whatever reason, using standard headers in modules imported from
Swift code (i.e. depending on Darwin overlay) is no longer an issue.

rdar://115438609
2023-10-04 15:12:17 -07:00