Skip to content

[Syntax] Remove unnecessary special attribute arguments syntax kinds #3028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 13 additions & 180 deletions CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,86 +61,67 @@ public let ATTRIBUTE_NODES: [Node] = [
kind: .nodeChoices(choices: [
Child(
name: "argumentList",
// Regular function-like attribute arguments.
kind: .node(kind: .labeledExprList)
),
Child(
name: "token",
kind: .node(kind: .token)
),
Child(
name: "string",
kind: .node(kind: .stringLiteralExpr)
),
Child(
name: "availability",
// Special arguments for platform versions.
kind: .node(kind: .availabilityArgumentList)
),
Child(
name: "specializeArguments",
// Special arguments for keyword decl name e.g. 'subscript(_:)', and availability arguments.
kind: .node(kind: .specializeAttributeArgumentList)
),
Child(
name: "objCName",
// Special arguments for Objective-C names. e.g. 'methodNameWithArg1:Arg2:'
kind: .node(kind: .objCSelectorPieceList)
),
Child(
name: "implementsArguments",
// Special arguments for keyword decl name e.g. 'subscript(_:)'.
kind: .node(kind: .implementsAttributeArguments)
),
Child(
name: "differentiableArguments",
// Special arguments for 'where' clause.
kind: .node(kind: .differentiableAttributeArguments)
),
Child(
name: "derivativeRegistrationArguments",
// Special arguments for 'where' clause.
kind: .node(kind: .derivativeAttributeArguments)
),
Child(
name: "backDeployedArguments",
// Special arguments for platform versions.
kind: .node(kind: .backDeployedAttributeArguments)
),
Child(
name: "conventionArguments",
kind: .node(kind: .conventionAttributeArguments)
),
Child(
name: "conventionWitnessMethodArguments",
kind: .node(kind: .conventionWitnessMethodAttributeArguments)
),
Child(
name: "opaqueReturnTypeOfAttributeArguments",
kind: .node(kind: .opaqueReturnTypeOfAttributeArguments)
),
Child(
name: "exposeAttributeArguments",
kind: .node(kind: .exposeAttributeArguments)
),
Child(
name: "originallyDefinedInArguments",
// Special arguments for platform versions.
kind: .node(kind: .originallyDefinedInAttributeArguments)
),
Child(
name: "underscorePrivateAttributeArguments",
kind: .node(kind: .underscorePrivateAttributeArguments)
),
Child(
name: "dynamicReplacementArguments",
// Special arguments for keyword decl name e.g. 'subscript(_:)'.
kind: .node(kind: .dynamicReplacementAttributeArguments)
),
Child(
name: "unavailableFromAsyncArguments",
kind: .node(kind: .unavailableFromAsyncAttributeArguments)
),
Child(
name: "effectsArguments",
// Special arguments for arbitrary token list, processed in SIL.
kind: .node(kind: .effectsAttributeArgumentList)
),
Child(
name: "documentationArguments",
// Special arguments for access-level keywords. E.g. 'private'.
kind: .node(kind: .documentationAttributeArgumentList)
),
Child(
name: "abiArguments",
// Special arguments for declaration syntax. e.g. @abi(func abiName() -> Int)
kind: .node(kind: .abiAttributeArguments),
experimentalFeature: .abiAttribute
),
Expand Down Expand Up @@ -296,65 +277,6 @@ public let ATTRIBUTE_NODES: [Node] = [
]
),

Node(
kind: .conventionAttributeArguments,
base: .syntax,
nameForDiagnostics: "@convention(...) arguments",
documentation: "The arguments for the '@convention(...)'.",
children: [
Child(
name: "conventionLabel",
kind: .token(choices: [.token(.identifier)]),
documentation: "The convention label."
),
Child(
name: "comma",
kind: .token(choices: [.token(.comma)]),
isOptional: true
),
Child(
name: "cTypeLabel",
kind: .token(choices: [.keyword(.cType)]),
isOptional: true
),
Child(
name: "colon",
kind: .token(choices: [.token(.colon)]),
isOptional: true
),
Child(
name: "cTypeString",
kind: .node(kind: .stringLiteralExpr),
isOptional: true
),
]
),

Node(
kind: .conventionWitnessMethodAttributeArguments,
base: .syntax,
nameForDiagnostics: "@convention(...) arguments for witness methods",
documentation: "The arguments for the '@convention(witness_method: ...)'.",
children: [
Child(
name: "witnessMethodLabel",
kind: .token(choices: [.keyword(.witness_method)]),
documentation: #"The `witnessMethod` label."#
),
Child(
name: "colon",
kind: .token(choices: [.token(.colon)]),
documentation: #"The colon separating the `witnessMethod` label and the original protocol name."#

),
Child(
name: "protocolName",
kind: .token(choices: [.token(.identifier)]),
documentation: "The original protocol name."
),
]
),

Node(
kind: .derivativeAttributeArguments,
base: .syntax,
Expand Down Expand Up @@ -653,29 +575,6 @@ public let ATTRIBUTE_NODES: [Node] = [
elementChoices: [.token]
),

Node(
kind: .exposeAttributeArguments,
base: .syntax,
nameForDiagnostics: "@_expose arguments",
documentation: "The arguments for the '@_expose' attribute",
children: [
Child(
name: "language",
kind: .node(kind: .token)
),
Child(
name: "comma",
kind: .token(choices: [.token(.comma)]),
isOptional: true
),
Child(
name: "cxxName",
kind: .node(kind: .stringLiteralExpr),
isOptional: true
),
]
),

Node(
kind: .implementsAttributeArguments,
base: .syntax,
Expand Down Expand Up @@ -780,29 +679,6 @@ public let ATTRIBUTE_NODES: [Node] = [
elementChoices: [.objCSelectorPiece]
),

Node(
kind: .opaqueReturnTypeOfAttributeArguments,
base: .syntax,
nameForDiagnostics: "opaque return type arguments",
documentation: "The arguments for the '@_opaqueReturnTypeOf()'.",
children: [
Child(
name: "mangledName",
kind: .node(kind: .stringLiteralExpr),
documentation: "The mangled name of a declaration."
),
Child(
name: "comma",
kind: .token(choices: [.token(.comma)])
),
Child(
name: "ordinal",
kind: .token(choices: [.token(.integerLiteral)]),
documentation: "The ordinal corresponding to the 'some' keyword that introduced this opaque type."
),
]
),

Node(
kind: .originallyDefinedInAttributeArguments,
base: .syntax,
Expand Down Expand Up @@ -884,47 +760,4 @@ public let ATTRIBUTE_NODES: [Node] = [
]
]
),

Node(
kind: .unavailableFromAsyncAttributeArguments,
base: .syntax,
nameForDiagnostics: "@_unavailableFromAsync argument",
documentation: "The arguments for the '@_unavailableFromAsync' attribute",
children: [
Child(
name: "messageLabel",
kind: .token(choices: [.keyword(.message)])
),
Child(
name: "colon",
kind: .token(choices: [.token(.colon)])
),
Child(
name: "message",
kind: .node(kind: .stringLiteralExpr)
),
]
),

Node(
kind: .underscorePrivateAttributeArguments,
base: .syntax,
nameForDiagnostics: "@_private argument",
documentation: "The arguments for the '@_private' attribute",
children: [
Child(
name: "sourceFileLabel",
kind: .token(choices: [.keyword(.sourceFile)])
),
Child(
name: "colon",
kind: .token(choices: [.token(.colon)])
),
Child(
name: "filename",
kind: .node(kind: .stringLiteralExpr)
),
]
),

]
Loading