Commit Graph

725 Commits

Author SHA1 Message Date
Anthony Latsis
fa1c9fd506 ASTGen: Translate enum case declarations 2023-09-12 20:37:50 +03:00
Anthony Latsis
4a5325a25a ASTGen: Translate enumeration declarations 2023-09-12 20:37:50 +03:00
Anthony Latsis
b4b4a58688 ASTGen: Translate actor declarations 2023-09-12 20:37:50 +03:00
Anthony Latsis
ca8f911b62 ASTGen: Translate generic where clauses 2023-09-12 20:37:50 +03:00
Anthony Latsis
b6be6da277 ASTGen: Translate associated type declarations
Plus tweak `DefaultDefinitionTypeRequest` caching to support querying the
cached type when dumping. This fixes a crash where type computation is
triggered in the dumper before import resolution in `-dump-parse` mode.
2023-09-12 20:37:50 +03:00
Anthony Latsis
da427adaa6 ASTGen: Translate inheritance clauses 2023-09-12 20:37:50 +03:00
Anthony Latsis
345a7f8aad ASTGen: Translate protocol declarations 2023-09-12 20:37:50 +03:00
Anthony Latsis
a49bf1986a ASTGen: Translate class generic parameter clauses 2023-09-12 20:37:50 +03:00
Anthony Latsis
7b25bfcab7 ASTGen: Translate function generic parameter clauses 2023-09-12 20:37:50 +03:00
Anthony Latsis
6293332cba ASTGen: Translate default arguments 2023-09-12 20:37:50 +03:00
Anthony Latsis
808ab1b064 [NFC] ASTGen: Extract ParamDecl and ParameterList translation into a new file 2023-09-12 20:37:50 +03:00
Anthony Latsis
034a39a00c ASTGen: Set brace locations for iterable declaration contexts 2023-09-12 20:37:50 +03:00
Anthony Latsis
1291333fde ASTGen: Cache parsed IterableDeclContext members using the request evaluator
...instead of adding them to the iterable context lest they be re-parsed using
the legacy parser and later re-added through `IterableDeclContext::loadAllMembers`.
2023-09-12 20:37:50 +03:00
Anthony Latsis
a141fba7fc [NFC] ASTGen: Don't unnecessarily bridge TypeAliasDecl::setUnderlyingTypeRepr 2023-09-12 20:37:50 +03:00
Anthony Latsis
4b314a7c9a ASTGen: Fix enough source locations that we can start diffing AST dumps
... and tidy up adjacent code along the way.
2023-09-12 20:37:50 +03:00
Anthony Latsis
4b2cdedc48 ASTGen: Start diagnosing instances of an invalid syntax tree 2023-09-12 20:37:50 +03:00
Anthony Latsis
e72b421fa4 [NFC] ASTGen: Rename "Diagnostics.swift" → "DiagnosticsBridge.swift"
This file deals with emitting SwiftSyntax diagnostics via the C++ engine and
rendering C++ diagnostics via SwiftSyntax rather than ASTGen diagnostics.
2023-09-12 20:37:50 +03:00
Anthony Latsis
cd55d760ed ASTGen: Skip leading trivia when forming bridged source locations 2023-09-12 20:37:49 +03:00
Anthony Latsis
ea164cd0a0 [NFC] ASTGen: Optimize and flatten the transform + withBridgedArrayRef pattern via bump allocation
To encourage usage of  lazy transformations, define `bridgedArrayRef`
on `LazyCollectionProtocol`.
2023-09-12 20:33:39 +03:00
Anthony Latsis
92c1bdc219 [NFC] ASTGen: Define visit(_:) overloads that take an optional to achieve consistent self.visit recursion pattern 2023-09-12 13:33:47 +03:00
Anthony Latsis
59c2623aba [NFC] ASTGen: Extract TokenSyntaxBridgedIdentifier mapping into a method 2023-09-12 13:33:47 +03:00
Anthony Latsis
3e0c368022 [NFC] ASTGen: Rename "Misc.swift" → "Bridge.swift" 2023-09-12 13:33:47 +03:00
Anthony Latsis
af6bfe9b9b [NFC] ASTGen: Move visit methods from "Misc.swift" to "ASTGen.swift"
Also, delete `func visit(_ node: LabeledExprSyntax)` as unused. We directly
visit its children instead, since it’s more than an expression.
2023-09-12 13:33:46 +03:00
Anthony Latsis
655e4c19a9 [NFC] ASTGen: Remove unused SwiftParser imports 2023-09-12 13:33:46 +03:00
Saleem Abdulrasool
e9e25ccfd0 Merge pull request #68323 from compnerd/workaround
ASTGen: add a workaround for CSC conformance visibility
2023-09-05 07:32:09 -07:00
Doug Gregor
9c7639d9ee Merge pull request #68289 from DougGregor/swiftsyntax-diags-cleanup 2023-09-05 06:44:04 -07:00
Saleem Abdulrasool
5d0c5a643f ASTGen: add a workaround for CSC conformance visibility
A thrown error is stored as `any Error` which does not conform to
`CustomStringConvertible`.  When we perform the conversion via the
`String(describing:)` initialiser, for some reason the runtime does not
find the conformance and the error is not translated properly.
Explicitly casting to `PluginError` resolves the missing conformance and
fixes a test failure.
2023-09-04 16:14:46 -07:00
Saleem Abdulrasool
a61e6e709c ASTGen: special case the Apple and Linux platforms
There is no real reason to split the behaviour here as this is a file
system primitive.  Special case Apple and Linux platforms to address
feedback.
2023-09-03 10:51:00 -07:00
Saleem Abdulrasool
284ef2015e ASTGen: account for alternate path separators
Windows supports `\` and `/` as path separators.  Account for both in
computing the basename.  This repairs a few test failures on Windows.
2023-09-03 10:48:57 -07:00
Doug Gregor
3e4dd4304a Merge pull request #68278 from DougGregor/swift-int-type-bridging 2023-09-01 23:36:19 -07:00
Doug Gregor
448402c608 [Diagnostics] Free memory associated with printed string 2023-09-01 22:03:09 -07:00
Saleem Abdulrasool
eaa856d123 ASTGen: adjust for type changes
The type definitions do not uniformly import as `Swift.Int` and `Swift.UInt`.  Add some casts to accommodate the type conversions.
2023-09-01 20:50:36 -07:00
Doug Gregor
13c849c930 Add support for the "remark" diagnostic severity 2023-09-01 17:40:18 -07:00
Doug Gregor
566c71ff30 Fix handling of Swift(U)Int for Windows 2023-09-01 14:47:58 -07:00
Doug Gregor
be82d0b8ae Merge pull request #68271 from DougGregor/no-free-for-you 2023-09-01 14:37:42 -07:00
Doug Gregor
ab44d474c3 [Macros] Replace use of free for Swift-allocated pointer
We cannot depend on Swift's unsafe pointers using `malloc` under the
hood, so don't use `free` on them. Instead, expose entry points from
Swift to C++ to free any Swift-allocated data structures that need to
be deallocated from C++.
2023-09-01 11:04:24 -07:00
Hamish Knight
6ee44f09b4 Introduce then statements
These allow multi-statement `if`/`switch` expression
branches that can produce a value at the end by
saying `then <expr>`. This is gated behind
`-enable-experimental-feature ThenStatements`
pending evolution discussion.
2023-09-01 14:32:14 +01:00
Alex Hoppen
5ab33b44b1 Merge pull request #67836 from ahoppen/ahoppen/no-optional-collections
[ASTGen/Macros] Update for the fact that syntax collections are always non-optional in SwiftSyntax now
2023-08-11 15:27:27 -07:00
Alex Hoppen
8231b272ba [ASTGen/Macros] Update for the fact that syntax collections are always non-optional in SwiftSyntax now 2023-08-11 07:46:59 -07:00
Hamish Knight
35a98f3828 [ASTGen] Allow querying of enabled features
For now this is using C interop, we ought to be
using C++ interop, but that's a much bigger
change.
2023-08-09 19:35:50 +01:00
Hamish Knight
33028a7cc4 Update for SyntaxTransformVisitor SPI 2023-08-09 19:35:49 +01:00
Alex Hoppen
2890e292bd [ASTGen] Fix swift-syntax deprecation warnings 2023-08-03 10:44:09 -07:00
John McCall
1a7d44a11d Diagnose attempts to reabstract variadic function types in unimplementable ways. 2023-07-18 13:22:35 -04:00
Holly Borla
48637c67d9 [ASTGen] Fix a silly typo that caused a bogus protocol conformance list to be
passed to extension macro expansion on the plugin server code path.
2023-07-07 19:18:33 -07:00
Rintaro Ishizaki
928c94ff13 [Macros] PluginMessages aren't @_spi anymore
rdar://111748087
2023-07-05 15:05:07 -07:00
Holly Borla
0bd898eb12 [Macros] Allow extension macros to suppress conformances that are already
stated in the original source.

If an extension macro can introduce protocol conformances, macro expansion
will check which of those protocols already have a stated conformance in the
original source. The protocols that don't will be passed as arguments to
extension macro expansion, indicating to the macro that it should only add
conformances to those protocols.
2023-06-30 16:01:15 -07:00
Rintaro Ishizaki
3e9c2536f6 [Macros] Unify PluginMessages.swift
Use PluginMessages.swift in swift-syntax consistently.
2023-06-29 13:04:10 -07:00
Holly Borla
43e2026a6e [ASTGen] The 'extendedType' argument for attached macros does not have a
source location.
2023-06-28 22:56:42 -07:00
Holly Borla
c3bdae6a30 [ASTGen] Sync PluginMessages.swift with the SwiftSyntax changes for extension
macros.
2023-06-28 13:56:50 -07:00
Holly Borla
d3e2562cd9 [Macros] Pass a qualified extended type to extension macro expansion. 2023-06-27 21:22:12 -07:00