From cc91c8cf6675dbdb12d442fae62cadeb0c5dc713 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Wed, 9 Aug 2023 13:26:22 -0700 Subject: [PATCH 1/2] [Macros] Update help message for '-load-plugin-executable' Clarify the format of the option and semantics. rdar://113646544 --- include/swift/Option/Options.td | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/swift/Option/Options.td b/include/swift/Option/Options.td index dcaeec6876b06..6e5f7cae29689 100644 --- a/include/swift/Option/Options.td +++ b/include/swift/Option/Options.td @@ -1823,8 +1823,8 @@ def load_plugin_library: def load_plugin_executable: Separate<["-"], "load-plugin-executable">, Group, Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>, - HelpText<"Path to an executable compiler plugins and providing module names " - "such as macros">, + HelpText<"Path to a compiler plugin executable and a comma-separated list " + "of module names where the macro types are declared">, MetaVarName<"#">; include "FrontendOptions.td" From 1243036d833be88799831f42c2ccee44213c0a73 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Thu, 10 Aug 2023 20:19:52 -0700 Subject: [PATCH 2/2] [Diagnostics] Reduce missing external macro diagnostic This is a very large diagnostic, where the second half is mostly aimed at macro authors rather than clients. Cut it down to the base diagnostic. Resolves rdar://113646544. --- include/swift/AST/DiagnosticsSema.def | 4 +--- test/Macros/macro_plugin_broken.swift | 4 ++-- test/Macros/macros_diagnostics.swift | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index d1d61706b35eb..563561f91ece8 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -7113,9 +7113,7 @@ ERROR(macro_undefined,PointsToFirstBadToken, "no macro named %0", (Identifier)) ERROR(external_macro_not_found,none, "external macro implementation type '%0.%1' could not be found for " - "macro %2; the type must be public and provided by a macro target in a " - "Swift package, or via '-plugin-path' or '-load-plugin-library'", - (StringRef, StringRef, DeclName)) + "macro %2", (StringRef, StringRef, DeclName)) ERROR(macro_must_be_defined,none, "macro %0 requires a definition", (DeclName)) ERROR(external_macro_outside_macro_definition,none, diff --git a/test/Macros/macro_plugin_broken.swift b/test/Macros/macro_plugin_broken.swift index 55fb3bbe8be22..6ec89f4050ffb 100644 --- a/test/Macros/macro_plugin_broken.swift +++ b/test/Macros/macro_plugin_broken.swift @@ -20,8 +20,8 @@ // RUN: c-index-test -read-diagnostics %t/macro_expand.dia 2>&1 | %FileCheck -check-prefix CHECK %s // CHECK: (null):0:0: warning: compiler plugin not loaded: {{.+}}broken-plugin; failed to initialize -// CHECK: test.swift:1:33: warning: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; -// CHECK: test.swift:4:7: error: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro'; +// CHECK: test.swift:1:33: warning: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro' +// CHECK: test.swift:4:7: error: external macro implementation type 'TestPlugin.FooMacro' could not be found for macro 'fooMacro' // CHECK: +-{{.+}}test.swift:1:33: note: 'fooMacro' declared here //--- test.swift diff --git a/test/Macros/macros_diagnostics.swift b/test/Macros/macros_diagnostics.swift index f6ec5a5f5093b..0c6ba47d8e8c7 100644 --- a/test/Macros/macros_diagnostics.swift +++ b/test/Macros/macros_diagnostics.swift @@ -136,7 +136,7 @@ func shadow(a: Int, b: Int, stringify: Int) { } func testMissing() { - #missingMacro1("hello") // expected-error{{external macro implementation type 'MissingModule.MissingType' could not be found for macro 'missingMacro1'; the type must be public and provided by a macro target in a Swift package, or via '-plugin-path' or '-load-plugin-library'}} + #missingMacro1("hello") // expected-error{{external macro implementation type 'MissingModule.MissingType' could not be found for macro 'missingMacro1'}} } @freestanding(expression) macro undefined() // expected-error{{macro 'undefined()' requires a definition}}