Swift: Remove SwiftDiagnostic constructor (C++20 todo).

This commit is contained in:
Alexandre Boulgakov
2023-06-08 13:11:14 +01:00
parent 838130ca3a
commit 5450585c1c
4 changed files with 41 additions and 48 deletions

View File

@@ -62,17 +62,6 @@ struct SwiftDiagnostic {
std::optional<SwiftDiagnosticsLocation> 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 <typename... OptionalArgs>
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/<prog name>/<id>`
@@ -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

View File

@@ -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() {

View File

@@ -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"};

View File

@@ -13,21 +13,22 @@ static constexpr std::string_view unknownType = "<unknown_target_type>";
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"};