Skip to content

Commit c3f1a84

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents f86b2c8 + b90cdca commit c3f1a84

File tree

262 files changed

+12177
-4679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+12177
-4679
lines changed

BUILD.bazel

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,42 @@ swift_syntax_test(
8383
],
8484
)
8585

86+
swift_syntax_library(
87+
name = "SwiftIfConfig",
88+
deps = [
89+
":SwiftDiagnostics",
90+
":SwiftOperators",
91+
":SwiftSyntax",
92+
":SwiftSyntaxBuilder",
93+
],
94+
)
95+
96+
swift_syntax_test(
97+
name = "SwiftIfConfigTest",
98+
deps = [
99+
":SwiftIfConfig",
100+
":SwiftParser",
101+
":SwiftSyntaxMacrosGenericTestSupport",
102+
":_SwiftSyntaxTestSupport",
103+
],
104+
)
105+
106+
swift_syntax_library(
107+
name = "SwiftLexicalLookup",
108+
deps = [
109+
":SwiftIfConfig",
110+
":SwiftSyntax",
111+
],
112+
)
113+
114+
swift_syntax_test(
115+
name = "SwiftLexicalLookupTest",
116+
deps = [
117+
":SwiftLexicalLookup",
118+
":_SwiftSyntaxTestSupport",
119+
],
120+
)
121+
86122
swift_syntax_library(
87123
name = "SwiftLibraryPluginProvider",
88124
deps = [
@@ -196,6 +232,13 @@ swift_syntax_library(
196232
],
197233
)
198234

235+
swift_syntax_library(
236+
name = "SwiftSyntax601",
237+
srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax601/**/*.swift"]),
238+
deps = [
239+
],
240+
)
241+
199242
swift_syntax_library(
200243
name = "SwiftSyntaxBuilder",
201244
deps = [

CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,11 @@ option(SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26
4444
include(AddSwiftHostLibrary)
4545
include(SwiftCompilerCapability)
4646

47-
# Don't link with 'string-processing' and 'backtracing'.
47+
# Don't link with 'string-processing'
4848
swift_supports_implicit_module("string-processing" SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
49-
swift_supports_implicit_module("backtracing" SWIFT_SUPPORTS_DISABLE_IMPLICIT_BACKTRACING_MODULE_IMPORT)
5049
if(SWIFT_SUPPORTS_DISABLE_IMPLICIT_STRING_PROCESSING_MODULE_IMPORT)
5150
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-string-processing-module-import>")
5251
endif()
53-
if(SWIFT_SUPPORTS_DISABLE_IMPLICIT_BACKTRACING_MODULE_IMPORT)
54-
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-backtracing-module-import>")
55-
endif()
5652

5753
if(NOT DEFINED Swift_COMPILER_PACKAGE_CMO_SUPPORT AND SWIFTSYNTAX_EMIT_MODULE)
5854
swift_get_package_cmo_support(Swift_COMPILER_PACKAGE_CMO_SUPPORT)

CONTRIBUTING.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ Once you've pushed your branch, you should see an option on this repository's pa
8484
> [!TIP]
8585
> If you are stuck, it’s encouraged to submit a PR that describes the issue you’re having, e.g. if there are tests that are failing, build failures you can’t resolve, or if you have architectural questions. We’re happy to work with you to resolve those issue.
8686
87-
## Opening a PR for Release Branch
87+
### Opening a PR for Release Branch
8888

89-
See the [dedicated section][section] on the Swift project website.
89+
See the [dedicated section](https://www.swift.org/contributing/#release-branch-pull-requests) on the Swift project website.
9090

91-
[section]: https://www.swift.org/contributing/#release-branch-pull-requests
91+
## Changing public API
92+
93+
If you are modifying public API, request feedback for these changes from the community by opening a RFC as described by the [RFC Process](Contributor%20Documentation/RFC%20Process.md).
9294

9395
## Review and CI Testing
9496

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ public let ATTRIBUTE_NODES: [Node] = [
139139
name: "documentationArguments",
140140
kind: .node(kind: .documentationAttributeArgumentList)
141141
),
142+
Child(
143+
name: "abiArguments",
144+
kind: .node(kind: .abiAttributeArguments),
145+
experimentalFeature: .abiAttribute
146+
),
142147
]),
143148
documentation: """
144149
The arguments of the attribute.
@@ -267,6 +272,30 @@ public let ATTRIBUTE_NODES: [Node] = [
267272
]
268273
),
269274

275+
Node(
276+
kind: .abiAttributeArguments,
277+
base: .syntax,
278+
experimentalFeature: .abiAttribute,
279+
nameForDiagnostics: "ABI-providing declaration",
280+
documentation: "The arguments of the '@abi' attribute",
281+
children: [
282+
Child(
283+
name: "provider",
284+
kind: .nodeChoices(choices: [
285+
Child(name: "associatedType", kind: .node(kind: .associatedTypeDecl)),
286+
Child(name: "deinitializer", kind: .node(kind: .deinitializerDecl)),
287+
Child(name: "enumCase", kind: .node(kind: .enumCaseDecl)),
288+
Child(name: "function", kind: .node(kind: .functionDecl)),
289+
Child(name: "initializer", kind: .node(kind: .initializerDecl)),
290+
Child(name: "missing", kind: .node(kind: .missingDecl)),
291+
Child(name: "subscript", kind: .node(kind: .subscriptDecl)),
292+
Child(name: "typeAlias", kind: .node(kind: .typeAliasDecl)),
293+
Child(name: "variable", kind: .node(kind: .variableDecl)),
294+
])
295+
)
296+
]
297+
),
298+
270299
Node(
271300
kind: .conventionAttributeArguments,
272301
base: .syntax,
@@ -356,7 +385,7 @@ public let ATTRIBUTE_NODES: [Node] = [
356385
),
357386
Child(
358387
name: "accessorSpecifier",
359-
kind: .token(choices: [.keyword(.get), .keyword(.set)]),
388+
kind: .token(choices: [.keyword(.get), .keyword(.set), .keyword(._modify)]),
360389
documentation: "The accessor name.",
361390
isOptional: true
362391
),

CodeGeneration/Sources/SyntaxSupport/Child.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ public class Child: NodeChoiceConvertible {
9393
/// Whether this child is optional and can be `nil`.
9494
public let isOptional: Bool
9595

96+
/// Whether this child provides a default value when used as a parameter in a function.
97+
public let providesDefaultInitialization: Bool
98+
9699
public let experimentalFeature: ExperimentalFeature?
97100

98101
/// A name of this child that can be shown in diagnostics.
@@ -303,6 +306,7 @@ public class Child: NodeChoiceConvertible {
303306
nameForDiagnostics: String? = nil,
304307
documentation: String? = nil,
305308
isOptional: Bool = false,
309+
providesDefaultInitialization: Bool = true,
306310
newerChildPath: [Child] = []
307311
) {
308312
precondition(name.first?.isLowercase ?? true, "The first letter of a child’s name should be lowercase")
@@ -314,6 +318,7 @@ public class Child: NodeChoiceConvertible {
314318
self.documentationSummary = SwiftSyntax.Trivia.docCommentTrivia(from: documentation)
315319
self.documentationAbstract = String(documentation?.split(whereSeparator: \.isNewline).first ?? "")
316320
self.isOptional = isOptional
321+
self.providesDefaultInitialization = providesDefaultInitialization
317322
}
318323

319324
/// Create a node that is a copy of the last node in `newerChildPath`, but
@@ -329,6 +334,7 @@ public class Child: NodeChoiceConvertible {
329334
self.documentationSummary = other.documentationSummary
330335
self.documentationAbstract = other.documentationAbstract
331336
self.isOptional = other.isOptional
337+
self.providesDefaultInitialization = other.providesDefaultInitialization
332338
}
333339

334340
/// Create a child for the unexpected nodes between two children (either or
@@ -353,6 +359,7 @@ public class Child: NodeChoiceConvertible {
353359
nameForDiagnostics: nil,
354360
documentation: nil,
355361
isOptional: true,
362+
providesDefaultInitialization: true,
356363
newerChildPath: newerChildPath
357364
)
358365
}

CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public enum ExperimentalFeature: String, CaseIterable {
2020
case trailingComma
2121
case coroutineAccessors
2222
case valueGenerics
23+
case abiAttribute
24+
case unsafeExpression
2325

2426
/// The name of the feature as it is written in the compiler's `Features.def` file.
2527
public var featureName: String {
@@ -38,6 +40,10 @@ public enum ExperimentalFeature: String, CaseIterable {
3840
return "CoroutineAccessors"
3941
case .valueGenerics:
4042
return "ValueGenerics"
43+
case .abiAttribute:
44+
return "ABIAttribute"
45+
case .unsafeExpression:
46+
return "WarnUnsafe"
4147
}
4248
}
4349

@@ -58,6 +64,10 @@ public enum ExperimentalFeature: String, CaseIterable {
5864
return "coroutine accessors"
5965
case .valueGenerics:
6066
return "value generics"
67+
case .abiAttribute:
68+
return "@abi attribute"
69+
case .unsafeExpression:
70+
return "'unsafe' expression"
6171
}
6272
}
6373

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ public let EXPR_NODES: [Node] = [
180180
]
181181
),
182182

183+
Node(
184+
kind: .unsafeExpr,
185+
base: .expr,
186+
experimentalFeature: .unsafeExpression,
187+
nameForDiagnostics: "'unsafe' expression",
188+
children: [
189+
Child(
190+
name: "unsafeKeyword",
191+
kind: .token(choices: [.keyword(.unsafe)])
192+
),
193+
Child(
194+
name: "expression",
195+
kind: .node(kind: .expr)
196+
),
197+
]
198+
),
199+
183200
Node(
184201
kind: .binaryOperatorExpr,
185202
base: .expr,
@@ -944,7 +961,8 @@ public let EXPR_NODES: [Node] = [
944961
Child(
945962
name: "leftParen",
946963
kind: .token(choices: [.token(.leftParen)]),
947-
isOptional: true
964+
isOptional: true,
965+
providesDefaultInitialization: false
948966
),
949967
Child(
950968
name: "arguments",
@@ -954,7 +972,8 @@ public let EXPR_NODES: [Node] = [
954972
Child(
955973
name: "rightParen",
956974
kind: .token(choices: [.token(.rightParen)]),
957-
isOptional: true
975+
isOptional: true,
976+
providesDefaultInitialization: false
958977
),
959978
Child(
960979
name: "trailingClosure",

CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public enum Keyword: CaseIterable {
131131
case _underlyingVersion
132132
case _UnknownLayout
133133
case _version
134+
case abi
134135
case accesses
135136
case actor
136137
case addressWithNativeOwner
@@ -405,6 +406,8 @@ public enum Keyword: CaseIterable {
405406
return KeywordSpec("_UnknownLayout")
406407
case ._version:
407408
return KeywordSpec("_version")
409+
case .abi:
410+
return KeywordSpec("abi", experimentalFeature: .abiAttribute)
408411
case .accesses:
409412
return KeywordSpec("accesses")
410413
case .actor:

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
2222

2323
case _canImportExpr
2424
case _canImportVersionInfo
25+
case abiAttributeArguments
2526
case accessorBlock
2627
case accessorDecl
2728
case accessorDeclList
@@ -298,6 +299,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
298299
case unresolvedAsExpr
299300
case unresolvedIsExpr
300301
case unresolvedTernaryExpr
302+
case unsafeExpr
301303
case valueBindingPattern
302304
case variableDecl
303305
case versionComponent
@@ -340,14 +342,23 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
340342
return .identifier(rawValue)
341343
}
342344

345+
public var uppercasedFirstWordRawValue: String {
346+
switch self {
347+
case .abiAttributeArguments:
348+
"ABIAttributeArguments"
349+
default:
350+
rawValue.withFirstCharacterUppercased
351+
}
352+
}
353+
343354
public var syntaxType: TypeSyntax {
344355
switch self {
345356
case .syntax:
346357
return "Syntax"
347358
case .syntaxCollection:
348359
return "SyntaxCollection"
349360
default:
350-
return "\(raw: rawValue.withFirstCharacterUppercased)Syntax"
361+
return "\(raw: uppercasedFirstWordRawValue)Syntax"
351362
}
352363
}
353364

0 commit comments

Comments
 (0)