Skip to content

Commit ebfb9d6

Browse files
rintarobnbarham
authored andcommitted
[Syntax] Remove unnecessary special attribute arguments syntax kinds
Some attributes are expressed with the regular 'LabeledExprListSyntax' There's no need for special argument list syntax kind and keywords.
1 parent 94681ba commit ebfb9d6

32 files changed

+36
-3059
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 13 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -61,86 +61,67 @@ public let ATTRIBUTE_NODES: [Node] = [
6161
kind: .nodeChoices(choices: [
6262
Child(
6363
name: "argumentList",
64+
// Regular function-like attribute arguments.
6465
kind: .node(kind: .labeledExprList)
6566
),
66-
Child(
67-
name: "token",
68-
kind: .node(kind: .token)
69-
),
70-
Child(
71-
name: "string",
72-
kind: .node(kind: .stringLiteralExpr)
73-
),
7467
Child(
7568
name: "availability",
69+
// Special arguments for platform versions.
7670
kind: .node(kind: .availabilityArgumentList)
7771
),
7872
Child(
7973
name: "specializeArguments",
74+
// Special arguments for keyword decl name e.g. 'subscript(_:)', and availability arguments.
8075
kind: .node(kind: .specializeAttributeArgumentList)
8176
),
8277
Child(
8378
name: "objCName",
79+
// Special arguments for Objective-C names. e.g. 'methodNameWithArg1:Arg2:'
8480
kind: .node(kind: .objCSelectorPieceList)
8581
),
8682
Child(
8783
name: "implementsArguments",
84+
// Special arguments for keyword decl name e.g. 'subscript(_:)'.
8885
kind: .node(kind: .implementsAttributeArguments)
8986
),
9087
Child(
9188
name: "differentiableArguments",
89+
// Special arguments for 'where' clause.
9290
kind: .node(kind: .differentiableAttributeArguments)
9391
),
9492
Child(
9593
name: "derivativeRegistrationArguments",
94+
// Special arguments for 'where' clause.
9695
kind: .node(kind: .derivativeAttributeArguments)
9796
),
9897
Child(
9998
name: "backDeployedArguments",
99+
// Special arguments for platform versions.
100100
kind: .node(kind: .backDeployedAttributeArguments)
101101
),
102-
Child(
103-
name: "conventionArguments",
104-
kind: .node(kind: .conventionAttributeArguments)
105-
),
106-
Child(
107-
name: "conventionWitnessMethodArguments",
108-
kind: .node(kind: .conventionWitnessMethodAttributeArguments)
109-
),
110-
Child(
111-
name: "opaqueReturnTypeOfAttributeArguments",
112-
kind: .node(kind: .opaqueReturnTypeOfAttributeArguments)
113-
),
114-
Child(
115-
name: "exposeAttributeArguments",
116-
kind: .node(kind: .exposeAttributeArguments)
117-
),
118102
Child(
119103
name: "originallyDefinedInArguments",
104+
// Special arguments for platform versions.
120105
kind: .node(kind: .originallyDefinedInAttributeArguments)
121106
),
122-
Child(
123-
name: "underscorePrivateAttributeArguments",
124-
kind: .node(kind: .underscorePrivateAttributeArguments)
125-
),
126107
Child(
127108
name: "dynamicReplacementArguments",
109+
// Special arguments for keyword decl name e.g. 'subscript(_:)'.
128110
kind: .node(kind: .dynamicReplacementAttributeArguments)
129111
),
130-
Child(
131-
name: "unavailableFromAsyncArguments",
132-
kind: .node(kind: .unavailableFromAsyncAttributeArguments)
133-
),
134112
Child(
135113
name: "effectsArguments",
114+
// Special arguments for arbitrary token list, processed in SIL.
136115
kind: .node(kind: .effectsAttributeArgumentList)
137116
),
138117
Child(
139118
name: "documentationArguments",
119+
// Special arguments for access-level keywords. E.g. 'private'.
140120
kind: .node(kind: .documentationAttributeArgumentList)
141121
),
142122
Child(
143123
name: "abiArguments",
124+
// Special arguments for declaration syntax. e.g. @abi(func abiName() -> Int)
144125
kind: .node(kind: .abiAttributeArguments),
145126
experimentalFeature: .abiAttribute
146127
),
@@ -296,65 +277,6 @@ public let ATTRIBUTE_NODES: [Node] = [
296277
]
297278
),
298279

299-
Node(
300-
kind: .conventionAttributeArguments,
301-
base: .syntax,
302-
nameForDiagnostics: "@convention(...) arguments",
303-
documentation: "The arguments for the '@convention(...)'.",
304-
children: [
305-
Child(
306-
name: "conventionLabel",
307-
kind: .token(choices: [.token(.identifier)]),
308-
documentation: "The convention label."
309-
),
310-
Child(
311-
name: "comma",
312-
kind: .token(choices: [.token(.comma)]),
313-
isOptional: true
314-
),
315-
Child(
316-
name: "cTypeLabel",
317-
kind: .token(choices: [.keyword(.cType)]),
318-
isOptional: true
319-
),
320-
Child(
321-
name: "colon",
322-
kind: .token(choices: [.token(.colon)]),
323-
isOptional: true
324-
),
325-
Child(
326-
name: "cTypeString",
327-
kind: .node(kind: .stringLiteralExpr),
328-
isOptional: true
329-
),
330-
]
331-
),
332-
333-
Node(
334-
kind: .conventionWitnessMethodAttributeArguments,
335-
base: .syntax,
336-
nameForDiagnostics: "@convention(...) arguments for witness methods",
337-
documentation: "The arguments for the '@convention(witness_method: ...)'.",
338-
children: [
339-
Child(
340-
name: "witnessMethodLabel",
341-
kind: .token(choices: [.keyword(.witness_method)]),
342-
documentation: #"The `witnessMethod` label."#
343-
),
344-
Child(
345-
name: "colon",
346-
kind: .token(choices: [.token(.colon)]),
347-
documentation: #"The colon separating the `witnessMethod` label and the original protocol name."#
348-
349-
),
350-
Child(
351-
name: "protocolName",
352-
kind: .token(choices: [.token(.identifier)]),
353-
documentation: "The original protocol name."
354-
),
355-
]
356-
),
357-
358280
Node(
359281
kind: .derivativeAttributeArguments,
360282
base: .syntax,
@@ -653,29 +575,6 @@ public let ATTRIBUTE_NODES: [Node] = [
653575
elementChoices: [.token]
654576
),
655577

656-
Node(
657-
kind: .exposeAttributeArguments,
658-
base: .syntax,
659-
nameForDiagnostics: "@_expose arguments",
660-
documentation: "The arguments for the '@_expose' attribute",
661-
children: [
662-
Child(
663-
name: "language",
664-
kind: .node(kind: .token)
665-
),
666-
Child(
667-
name: "comma",
668-
kind: .token(choices: [.token(.comma)]),
669-
isOptional: true
670-
),
671-
Child(
672-
name: "cxxName",
673-
kind: .node(kind: .stringLiteralExpr),
674-
isOptional: true
675-
),
676-
]
677-
),
678-
679578
Node(
680579
kind: .implementsAttributeArguments,
681580
base: .syntax,
@@ -780,29 +679,6 @@ public let ATTRIBUTE_NODES: [Node] = [
780679
elementChoices: [.objCSelectorPiece]
781680
),
782681

783-
Node(
784-
kind: .opaqueReturnTypeOfAttributeArguments,
785-
base: .syntax,
786-
nameForDiagnostics: "opaque return type arguments",
787-
documentation: "The arguments for the '@_opaqueReturnTypeOf()'.",
788-
children: [
789-
Child(
790-
name: "mangledName",
791-
kind: .node(kind: .stringLiteralExpr),
792-
documentation: "The mangled name of a declaration."
793-
),
794-
Child(
795-
name: "comma",
796-
kind: .token(choices: [.token(.comma)])
797-
),
798-
Child(
799-
name: "ordinal",
800-
kind: .token(choices: [.token(.integerLiteral)]),
801-
documentation: "The ordinal corresponding to the 'some' keyword that introduced this opaque type."
802-
),
803-
]
804-
),
805-
806682
Node(
807683
kind: .originallyDefinedInAttributeArguments,
808684
base: .syntax,
@@ -884,47 +760,4 @@ public let ATTRIBUTE_NODES: [Node] = [
884760
]
885761
]
886762
),
887-
888-
Node(
889-
kind: .unavailableFromAsyncAttributeArguments,
890-
base: .syntax,
891-
nameForDiagnostics: "@_unavailableFromAsync argument",
892-
documentation: "The arguments for the '@_unavailableFromAsync' attribute",
893-
children: [
894-
Child(
895-
name: "messageLabel",
896-
kind: .token(choices: [.keyword(.message)])
897-
),
898-
Child(
899-
name: "colon",
900-
kind: .token(choices: [.token(.colon)])
901-
),
902-
Child(
903-
name: "message",
904-
kind: .node(kind: .stringLiteralExpr)
905-
),
906-
]
907-
),
908-
909-
Node(
910-
kind: .underscorePrivateAttributeArguments,
911-
base: .syntax,
912-
nameForDiagnostics: "@_private argument",
913-
documentation: "The arguments for the '@_private' attribute",
914-
children: [
915-
Child(
916-
name: "sourceFileLabel",
917-
kind: .token(choices: [.keyword(.sourceFile)])
918-
),
919-
Child(
920-
name: "colon",
921-
kind: .token(choices: [.token(.colon)])
922-
),
923-
Child(
924-
name: "filename",
925-
kind: .node(kind: .stringLiteralExpr)
926-
),
927-
]
928-
),
929-
930763
]

0 commit comments

Comments
 (0)