Skip to content

always use the argNames constructor for macro DeclNames #66497

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
Jun 12, 2023
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
12 changes: 4 additions & 8 deletions lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4910,14 +4910,10 @@ class DeclDeserializer {

// Resolve the name ids.
DeclName name;
if (numArgNames > 0) {
SmallVector<Identifier, 2> argNames;
for (auto argNameID : argNameAndDependencyIDs.slice(0, numArgNames))
argNames.push_back(MF.getIdentifier(argNameID));
name = DeclName(ctx, baseName, argNames);
} else {
name = baseName;
}
SmallVector<Identifier, 2> argNames;
for (auto argNameID : argNameAndDependencyIDs.slice(0, numArgNames))
argNames.push_back(MF.getIdentifier(argNameID));
name = DeclName(ctx, baseName, argNames);
PrettySupplementalDeclNameTrace trace(name);

argNameAndDependencyIDs = argNameAndDependencyIDs.slice(numArgNames);
Expand Down
2 changes: 1 addition & 1 deletion test/SourceKit/Refactoring/shorthand_shadow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func renameBuiltinMacroWithoutHash() {
// RUN: not %sourcekitd-test -req=find-local-rename-ranges -pos=%(line+1):9 %s -- %s 2>&1 | %FileCheck %s --check-prefix=BUILTIN
_ = file
}
// BUILTIN: error: cannot rename system symbol 'file'
// BUILTIN: error: cannot rename system symbol 'file()'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,32 @@
// 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/
// RUN: %{python} -m json.tool %t/Macros.symbols.json %t/Macros.formatted.symbols.json

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

// RUN: %FileCheck %s --input-file %t/Macros.formatted.symbols.json
// RUN: %FileCheck %s --input-file %t/Macros.formatted.symbols.json --check-prefix NAMES
// RUN: %FileCheck %s --input-file %t/Macros.formatted.symbols.json --check-prefix TITLE

// Now do the same thing with a `swift-symbolgraph-extract`-processed symbol graph.

// RUN: %empty-directory(%t)
// 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
// RUN: %target-swift-frontend -load-plugin-library %t/%target-library-name(MacroDefinition) %s -module-name Macros -emit-module -emit-module-path %t/Macros.swiftmodule
// RUN: %target-swift-symbolgraph-extract -module-name Macros -I %t -pretty-print -output-dir %t

// RUN: %FileCheck %s --input-file %t/Macros.symbols.json
// RUN: %FileCheck %s --input-file %t/Macros.symbols.json --check-prefix NAMES
// RUN: %FileCheck %s --input-file %t/Macros.symbols.json --check-prefix TITLE

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

@freestanding(expression) public macro stringifySeven() -> (Int, String) = #stringify(7)

// Note that type parameters don't have reference USRs when loading from serialized AST, so the
// following declaration/names dumps are edited to handle both situations.

// CHECK-LABEL: "precise": "s:6Macros9stringifyyx_SStxclufm",
// CHECK: "declarationFragments": [
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "attribute",
Expand Down Expand Up @@ -65,18 +83,16 @@
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "typeIdentifier",
// CHECK-NEXT: "spelling": "T",
// CHECK-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
// CHECK-NEXT: },
// CHECK-NEXT: "spelling": "T"
// CHECK: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "text",
// CHECK-NEXT: "spelling": ") -> ("
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "typeIdentifier",
// CHECK-NEXT: "spelling": "T",
// CHECK-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
// CHECK-NEXT: },
// CHECK-NEXT: "spelling": "T"
// CHECK: },
// CHECK-NEXT: {
// CHECK-NEXT: "kind": "text",
// CHECK-NEXT: "spelling": ", "
Expand All @@ -92,6 +108,7 @@
// CHECK-NEXT: }
// CHECK-NEXT: ],

// NAMES-LABEL: "precise": "s:6Macros9stringifyyx_SStxclufm",
// NAMES: "names": {
// NAMES-NEXT: "title": "stringify(_:)",
// NAMES-NEXT: "subHeading": [
Expand Down Expand Up @@ -121,18 +138,16 @@
// NAMES-NEXT: },
// NAMES-NEXT: {
// NAMES-NEXT: "kind": "typeIdentifier",
// NAMES-NEXT: "spelling": "T",
// NAMES-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
// NAMES-NEXT: },
// NAMES-NEXT: "spelling": "T"
// NAMES: },
// NAMES-NEXT: {
// NAMES-NEXT: "kind": "text",
// NAMES-NEXT: "spelling": ") -> ("
// NAMES-NEXT: },
// NAMES-NEXT: {
// NAMES-NEXT: "kind": "typeIdentifier",
// NAMES-NEXT: "spelling": "T",
// NAMES-NEXT: "preciseIdentifier": "s:6Macros1TL_xmfp"
// NAMES-NEXT: },
// NAMES-NEXT: "spelling": "T"
// NAMES: },
// NAMES-NEXT: {
// NAMES-NEXT: "kind": "text",
// NAMES-NEXT: "spelling": ", "
Expand All @@ -148,3 +163,6 @@
// NAMES-NEXT: }
// NAMES-NEXT: ]
// NAMES-NEXT: },

// TITLE-LABEL: "precise": "s:6Macros14stringifySevenSi_SStycfm",
// TITLE: "title": "stringifySeven()",