Skip to content

Commit 7ce1189

Browse files
committed
Swift: tweak after review comments
1 parent b5c0cd8 commit 7ce1189

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

swift/logging/SwiftDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::string SwiftDiagnosticsSource::sourceId() const {
4545
std::replace(ret.begin(), ret.end(), '_', '-');
4646
return ret;
4747
}
48-
void SwiftDiagnosticsSource::inscribeImpl(const SwiftDiagnosticsSource* source) {
48+
void SwiftDiagnosticsSource::registerImpl(const SwiftDiagnosticsSource* source) {
4949
auto [it, inserted] = map().emplace(source->id, source);
5050
CODEQL_ASSERT(inserted, "duplicate diagnostics source detected with id {}", source->id);
5151
}

swift/logging/SwiftDiagnostics.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ struct SwiftDiagnosticsSource {
2323
std::string_view name;
2424
static constexpr std::string_view extractorName = "swift";
2525
std::string_view action;
26-
std::string_view helpLinks; // space separated if more than 1. Not a vector to allow constexpr
26+
// space separated if more than 1. Not a vector to allow constexpr
27+
// TODO(C++20) with vector going constexpr this can be turned to `std::vector<std::string_view>`
28+
std::string_view helpLinks;
2729

2830
// for the moment, we only output errors, so no need to store the severity
2931

3032
// registers a diagnostics source for later retrieval with get, if not done yet
31-
template <const SwiftDiagnosticsSource* Spec>
32-
static void inscribe() {
33+
template <const SwiftDiagnosticsSource* Source>
34+
static void ensureRegistered() {
3335
static std::once_flag once;
34-
std::call_once(once, inscribeImpl, Spec);
36+
std::call_once(once, registerImpl, Source);
3537
}
3638

3739
// gets a previously inscribed SwiftDiagnosticsSource for the given id. Will abort if none exists
@@ -44,7 +46,7 @@ struct SwiftDiagnosticsSource {
4446
void emit(std::ostream& out, std::string_view timestamp, std::string_view message) const;
4547

4648
private:
47-
static void inscribeImpl(const SwiftDiagnosticsSource* Spec);
49+
static void registerImpl(const SwiftDiagnosticsSource* source);
4850

4951
std::string sourceId() const;
5052
using Map = std::unordered_map<std::string, const SwiftDiagnosticsSource*>;

0 commit comments

Comments
 (0)