Skip to content

Commit 5450585

Browse files
committed
Swift: Remove SwiftDiagnostic constructor (C++20 todo).
1 parent 838130c commit 5450585

File tree

4 files changed

+41
-48
lines changed

4 files changed

+41
-48
lines changed

swift/logging/SwiftDiagnostics.h

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,6 @@ struct SwiftDiagnostic {
6262

6363
std::optional<SwiftDiagnosticsLocation> location{};
6464

65-
// optional arguments can be either Severity or Visibility to set the corresponding field.
66-
// TODO(C++20) this constructor won't really be necessary anymore with designated initializers
67-
template <typename... OptionalArgs>
68-
constexpr SwiftDiagnostic(std::string_view id,
69-
std::string_view name,
70-
std::string_view action,
71-
OptionalArgs... optionalArgs)
72-
: id{id}, name{name}, action{action} {
73-
(setOptionalArg(optionalArgs), ...);
74-
}
75-
7665
// create a JSON diagnostics for this source with the given `timestamp` and Markdown `message`
7766
// A markdownMessage is emitted that includes both the message and the action to take. The id is
7867
// used to construct the source id in the form `swift/<prog name>/<id>`
@@ -116,14 +105,15 @@ inline constexpr SwiftDiagnostic::Visibility operator&(SwiftDiagnostic::Visibili
116105
}
117106

118107
constexpr SwiftDiagnostic internalError{
119-
"internal-error",
120-
"Internal error",
121-
"Some or all of the Swift analysis may have failed.\n"
122-
"\n"
123-
"If the error persists, contact support, quoting the error message and describing what "
124-
"happened, or [open an issue in our open source repository][1].\n"
125-
"\n"
126-
"[1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md",
127-
SwiftDiagnostic::Severity::warning,
108+
.id = "internal-error",
109+
.name = "Internal error",
110+
.action =
111+
"Some or all of the Swift analysis may have failed.\n"
112+
"\n"
113+
"If the error persists, contact support, quoting the error message and describing what "
114+
"happened, or [open an issue in our open source repository][1].\n"
115+
"\n"
116+
"[1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md",
117+
.severity = SwiftDiagnostic::Severity::warning,
128118
};
129119
} // namespace codeql

swift/tools/autobuilder-diagnostics/IncompatibleOs.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,21 @@
99
const std::string_view codeql::programName = "autobuilder";
1010

1111
constexpr codeql::SwiftDiagnostic incompatibleOs{
12-
"incompatible-os",
13-
"Incompatible operating system (expected macOS)",
14-
"[Change the Actions runner][1] to run on macOS.\n"
15-
"\n"
16-
"You may be able to run analysis on Linux by setting up a [manual build command][2].\n"
17-
"\n"
18-
"[1]: "
19-
"https://docs.github.com/en/actions/using-workflows/"
20-
"workflow-syntax-for-github-actions#jobsjob_idruns-on\n"
21-
"[2]: "
22-
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
23-
"automatically-scanning-your-code-for-vulnerabilities-and-errors/"
24-
"configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-"
25-
"language",
12+
.id = "incompatible-os",
13+
.name = "Incompatible operating system (expected macOS)",
14+
.action =
15+
"[Change the Actions runner][1] to run on macOS.\n"
16+
"\n"
17+
"You may be able to run analysis on Linux by setting up a [manual build command][2].\n"
18+
"\n"
19+
"[1]: "
20+
"https://docs.github.com/en/actions/using-workflows/"
21+
"workflow-syntax-for-github-actions#jobsjob_idruns-on\n"
22+
"[2]: "
23+
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
24+
"automatically-scanning-your-code-for-vulnerabilities-and-errors/"
25+
"configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-"
26+
"language",
2627
};
2728

2829
static codeql::Logger& logger() {

swift/xcode-autobuilder/XcodeBuildRunner.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
#include "swift/xcode-autobuilder/CustomizingBuildLink.h"
1010

1111
constexpr codeql::SwiftDiagnostic buildCommandFailed{
12-
"build-command-failed", "Detected build command failed",
13-
"Set up a [manual build command][1] or [check the logs of the autobuild step][2].\n"
14-
"\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK "\n[2]: " CHECK_LOGS_HELP_LINK};
12+
.id = "build-command-failed",
13+
.name = "Detected build command failed",
14+
.action = "Set up a [manual build command][1] or [check the logs of the autobuild step][2].\n"
15+
"\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK "\n[2]: " CHECK_LOGS_HELP_LINK};
1516

1617
static codeql::Logger& logger() {
1718
static codeql::Logger ret{"build"};

swift/xcode-autobuilder/xcode-autobuilder.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ static constexpr std::string_view unknownType = "<unknown_target_type>";
1313

1414
const std::string_view codeql::programName = "autobuilder";
1515

16-
constexpr codeql::SwiftDiagnostic noProjectFound{"no-project-found",
17-
"No Xcode project or workspace found",
18-
"Set up a [manual build command][1].\n"
19-
"\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK};
16+
constexpr codeql::SwiftDiagnostic noProjectFound{
17+
.id = "no-project-found",
18+
.name = "No Xcode project or workspace found",
19+
.action = "Set up a [manual build command][1].\n\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK};
2020

2121
constexpr codeql::SwiftDiagnostic noSwiftTarget{
22-
"no-swift-target", "No Swift compilation target found",
23-
"To analyze a custom set of source files, set up a [manual build command][1].\n"
24-
"\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK};
22+
.id = "no-swift-target",
23+
.name = "No Swift compilation target found",
24+
.action = "To analyze a custom set of source files, set up a [manual build "
25+
"command][1].\n\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK};
2526

2627
constexpr codeql::SwiftDiagnostic spmNotSupported{
27-
"spm-not-supported", "Swift Package Manager is not supported",
28-
"Swift Package Manager builds are not currently supported by `autobuild`. Set up a [manual "
29-
"build command][1].\n"
30-
"\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK};
28+
.id = "spm-not-supported",
29+
.name = "Swift Package Manager is not supported",
30+
.action = "Swift Package Manager builds are not currently supported by `autobuild`. Set up a "
31+
"[manual build command][1].\n\n[1]: " MANUAL_BUILD_COMMAND_HELP_LINK};
3132

3233
static codeql::Logger& logger() {
3334
static codeql::Logger ret{"main"};

0 commit comments

Comments
 (0)