diff --git a/swift/logging/SwiftDiagnostics.h b/swift/logging/SwiftDiagnostics.h index eb54421fd2b..e945e11b8e6 100644 --- a/swift/logging/SwiftDiagnostics.h +++ b/swift/logging/SwiftDiagnostics.h @@ -62,17 +62,6 @@ struct SwiftDiagnostic { std::optional location{}; - // optional arguments can be either Severity or Visibility to set the corresponding field. - // TODO(C++20) this constructor won't really be necessary anymore with designated initializers - template - constexpr SwiftDiagnostic(std::string_view id, - std::string_view name, - std::string_view action, - OptionalArgs... optionalArgs) - : id{id}, name{name}, action{action} { - (setOptionalArg(optionalArgs), ...); - } - // create a JSON diagnostics for this source with the given `timestamp` and Markdown `message` // A markdownMessage is emitted that includes both the message and the action to take. The id is // used to construct the source id in the form `swift//` @@ -116,14 +105,15 @@ inline constexpr SwiftDiagnostic::Visibility operator&(SwiftDiagnostic::Visibili } constexpr SwiftDiagnostic internalError{ - "internal-error", - "Internal error", - "Some or all of the Swift analysis may have failed.\n" - "\n" - "If the error persists, contact support, quoting the error message and describing what " - "happened, or [open an issue in our open source repository][1].\n" - "\n" - "[1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md", - SwiftDiagnostic::Severity::warning, + .id = "internal-error", + .name = "Internal error", + .action = + "Some or all of the Swift analysis may have failed.\n" + "\n" + "If the error persists, contact support, quoting the error message and describing what " + "happened, or [open an issue in our open source repository][1].\n" + "\n" + "[1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md", + .severity = SwiftDiagnostic::Severity::warning, }; } // namespace codeql diff --git a/swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp b/swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp index 2920a00f955..0bab7afbf69 100644 --- a/swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp +++ b/swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp @@ -9,20 +9,21 @@ const std::string_view codeql::programName = "autobuilder"; constexpr codeql::SwiftDiagnostic incompatibleOs{ - "incompatible-os", - "Incompatible operating system (expected macOS)", - "[Change the Actions runner][1] to run on macOS.\n" - "\n" - "You may be able to run analysis on Linux by setting up a [manual build command][2].\n" - "\n" - "[1]: " - "https://docs.github.com/en/actions/using-workflows/" - "workflow-syntax-for-github-actions#jobsjob_idruns-on\n" - "[2]: " - "https://docs.github.com/en/enterprise-server/code-security/code-scanning/" - "automatically-scanning-your-code-for-vulnerabilities-and-errors/" - "configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-" - "language", + .id = "incompatible-os", + .name = "Incompatible operating system (expected macOS)", + .action = + "[Change the Actions runner][1] to run on macOS.\n" + "\n" + "You may be able to run analysis on Linux by setting up a [manual build command][2].\n" + "\n" + "[1]: " + "https://docs.github.com/en/actions/using-workflows/" + "workflow-syntax-for-github-actions#jobsjob_idruns-on\n" + "[2]: " + "https://docs.github.com/en/enterprise-server/code-security/code-scanning/" + "automatically-scanning-your-code-for-vulnerabilities-and-errors/" + "configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-" + "language", }; static codeql::Logger& logger() { diff --git a/swift/xcode-autobuilder/XcodeBuildRunner.cpp b/swift/xcode-autobuilder/XcodeBuildRunner.cpp index eaf5e7c0355..567f726ad89 100644 --- a/swift/xcode-autobuilder/XcodeBuildRunner.cpp +++ b/swift/xcode-autobuilder/XcodeBuildRunner.cpp @@ -9,9 +9,10 @@ #include "swift/xcode-autobuilder/CustomizingBuildLink.h" constexpr codeql::SwiftDiagnostic buildCommandFailed{ - "build-command-failed", "Detected build command failed", - "Set up a [manual build command][1] or [check the logs of the autobuild step][2].\n" - "\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK "\n[2]: " CHECK_LOGS_HELP_LINK}; + .id = "build-command-failed", + .name = "Detected build command failed", + .action = "Set up a [manual build command][1] or [check the logs of the autobuild step][2].\n" + "\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK "\n[2]: " CHECK_LOGS_HELP_LINK}; static codeql::Logger& logger() { static codeql::Logger ret{"build"}; diff --git a/swift/xcode-autobuilder/xcode-autobuilder.cpp b/swift/xcode-autobuilder/xcode-autobuilder.cpp index 4cc234de66b..fa10a674edd 100644 --- a/swift/xcode-autobuilder/xcode-autobuilder.cpp +++ b/swift/xcode-autobuilder/xcode-autobuilder.cpp @@ -13,21 +13,22 @@ static constexpr std::string_view unknownType = ""; const std::string_view codeql::programName = "autobuilder"; -constexpr codeql::SwiftDiagnostic noProjectFound{"no-project-found", - "No Xcode project or workspace found", - "Set up a [manual build command][1].\n" - "\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK}; +constexpr codeql::SwiftDiagnostic noProjectFound{ + .id = "no-project-found", + .name = "No Xcode project or workspace found", + .action = "Set up a [manual build command][1].\n\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK}; constexpr codeql::SwiftDiagnostic noSwiftTarget{ - "no-swift-target", "No Swift compilation target found", - "To analyze a custom set of source files, set up a [manual build command][1].\n" - "\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK}; + .id = "no-swift-target", + .name = "No Swift compilation target found", + .action = "To analyze a custom set of source files, set up a [manual build " + "command][1].\n\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK}; constexpr codeql::SwiftDiagnostic spmNotSupported{ - "spm-not-supported", "Swift Package Manager is not supported", - "Swift Package Manager builds are not currently supported by `autobuild`. Set up a [manual " - "build command][1].\n" - "\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK}; + .id = "spm-not-supported", + .name = "Swift Package Manager is not supported", + .action = "Swift Package Manager builds are not currently supported by `autobuild`. Set up a " + "[manual build command][1].\n\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK}; static codeql::Logger& logger() { static codeql::Logger ret{"main"};