Skip to content

Commit e45c9df

Browse files
always use the argNames constructor for macro DeclNames (#66497)
rdar://110179186
1 parent dcb3b9b commit e45c9df

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5027,14 +5027,10 @@ class DeclDeserializer {
50275027

50285028
// Resolve the name ids.
50295029
DeclName name;
5030-
if (numArgNames > 0) {
5031-
SmallVector<Identifier, 2> argNames;
5032-
for (auto argNameID : argNameAndDependencyIDs.slice(0, numArgNames))
5033-
argNames.push_back(MF.getIdentifier(argNameID));
5034-
name = DeclName(ctx, baseName, argNames);
5035-
} else {
5036-
name = baseName;
5037-
}
5030+
SmallVector<Identifier, 2> argNames;
5031+
for (auto argNameID : argNameAndDependencyIDs.slice(0, numArgNames))
5032+
argNames.push_back(MF.getIdentifier(argNameID));
5033+
name = DeclName(ctx, baseName, argNames);
50385034
PrettySupplementalDeclNameTrace trace(name);
50395035

50405036
argNameAndDependencyIDs = argNameAndDependencyIDs.slice(numArgNames);

test/SourceKit/Refactoring/shorthand_shadow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func renameBuiltinMacroWithoutHash() {
3232
// RUN: not %sourcekitd-test -req=find-local-rename-ranges -pos=%(line+1):9 %s -- %s 2>&1 | %FileCheck %s --check-prefix=BUILTIN
3333
_ = file
3434
}
35-
// BUILTIN: error: cannot rename system symbol 'file'
35+
// BUILTIN: error: cannot rename system symbol 'file()'
3636
}
3737

3838

test/SymbolGraph/Symbols/Mixins/DeclarationFragments/Full/Macros.swift

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,32 @@
66
// RUN: %target-swift-frontend -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name Macros -emit-module -emit-module-path %t/Macros.swiftmodule -emit-symbol-graph -emit-symbol-graph-dir %t/
77
// RUN: %{python} -m json.tool %t/Macros.symbols.json %t/Macros.formatted.symbols.json
88

9-
// Make sure that the `= #externalMacro(...)` doesn't show up in declaration fragments and in names fragments.
9+
// Make sure that the `= #externalMacro(...)` doesn't show up in declaration fragments and in names
10+
// fragments, and also that macros with no parameters get the `()` in their name.
1011

1112
// RUN: %FileCheck %s --input-file %t/Macros.formatted.symbols.json
1213
// RUN: %FileCheck %s --input-file %t/Macros.formatted.symbols.json --check-prefix NAMES
14+
// RUN: %FileCheck %s --input-file %t/Macros.formatted.symbols.json --check-prefix TITLE
1315

16+
// Now do the same thing with a `swift-symbolgraph-extract`-processed symbol graph.
17+
18+
// RUN: %empty-directory(%t)
19+
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/stringify_macro.swift -g -no-toolchain-stdlib-rpath -swift-version 5
20+
// RUN: %target-swift-frontend -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name Macros -emit-module -emit-module-path %t/Macros.swiftmodule
21+
// RUN: %target-swift-symbolgraph-extract -module-name Macros -I %t -pretty-print -output-dir %t
22+
23+
// RUN: %FileCheck %s --input-file %t/Macros.symbols.json
24+
// RUN: %FileCheck %s --input-file %t/Macros.symbols.json --check-prefix NAMES
25+
// RUN: %FileCheck %s --input-file %t/Macros.symbols.json --check-prefix TITLE
1426

1527
@freestanding(expression) public macro stringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
1628

29+
@freestanding(expression) public macro stringifySeven() -> (Int, String) = #stringify(7)
30+
31+
// Note that type parameters don't have reference USRs when loading from serialized AST, so the
32+
// following declaration/names dumps are edited to handle both situations.
33+
34+
// CHECK-LABEL: "precise": "s:6Macros9stringifyyx_SStxclufm",
1735
// CHECK: "declarationFragments": [
1836
// CHECK-NEXT: {
1937
// CHECK-NEXT: "kind": "attribute",
@@ -65,18 +83,16 @@
6583
// CHECK-NEXT: },
6684
// CHECK-NEXT: {
6785
// CHECK-NEXT: "kind": "typeIdentifier",
68-
// CHECK-NEXT: "spelling": "T",
69-
// CHECK-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
70-
// CHECK-NEXT: },
86+
// CHECK-NEXT: "spelling": "T"
87+
// CHECK: },
7188
// CHECK-NEXT: {
7289
// CHECK-NEXT: "kind": "text",
7390
// CHECK-NEXT: "spelling": ") -> ("
7491
// CHECK-NEXT: },
7592
// CHECK-NEXT: {
7693
// CHECK-NEXT: "kind": "typeIdentifier",
77-
// CHECK-NEXT: "spelling": "T",
78-
// CHECK-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
79-
// CHECK-NEXT: },
94+
// CHECK-NEXT: "spelling": "T"
95+
// CHECK: },
8096
// CHECK-NEXT: {
8197
// CHECK-NEXT: "kind": "text",
8298
// CHECK-NEXT: "spelling": ", "
@@ -92,6 +108,7 @@
92108
// CHECK-NEXT: }
93109
// CHECK-NEXT: ],
94110

111+
// NAMES-LABEL: "precise": "s:6Macros9stringifyyx_SStxclufm",
95112
// NAMES: "names": {
96113
// NAMES-NEXT: "title": "stringify(_:)",
97114
// NAMES-NEXT: "subHeading": [
@@ -121,18 +138,16 @@
121138
// NAMES-NEXT: },
122139
// NAMES-NEXT: {
123140
// NAMES-NEXT: "kind": "typeIdentifier",
124-
// NAMES-NEXT: "spelling": "T",
125-
// NAMES-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
126-
// NAMES-NEXT: },
141+
// NAMES-NEXT: "spelling": "T"
142+
// NAMES: },
127143
// NAMES-NEXT: {
128144
// NAMES-NEXT: "kind": "text",
129145
// NAMES-NEXT: "spelling": ") -> ("
130146
// NAMES-NEXT: },
131147
// NAMES-NEXT: {
132148
// NAMES-NEXT: "kind": "typeIdentifier",
133-
// NAMES-NEXT: "spelling": "T",
134-
// NAMES-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
135-
// NAMES-NEXT: },
149+
// NAMES-NEXT: "spelling": "T"
150+
// NAMES: },
136151
// NAMES-NEXT: {
137152
// NAMES-NEXT: "kind": "text",
138153
// NAMES-NEXT: "spelling": ", "
@@ -148,3 +163,6 @@
148163
// NAMES-NEXT: }
149164
// NAMES-NEXT: ]
150165
// NAMES-NEXT: },
166+
167+
// TITLE-LABEL: "precise": "s:6Macros14stringifySevenSi_SStycfm",
168+
// TITLE: "title": "stringifySeven()",

0 commit comments

Comments
 (0)