Skip to content

Commit 838130c

Browse files
committed
Swift: Fix some C++20 todos.
1 parent 5952a72 commit 838130c

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

swift/extractor/trap/TrapLabel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#pragma once
22

3+
#include <bit>
34
#include <cassert>
45
#include <iomanip>
56
#include <iostream>
67
#include <string>
78
#include <vector>
8-
#include "absl/numeric/bits.h"
99
#include <binlog/binlog.hpp>
1010
#include <cmath>
1111
#include <charconv>
@@ -52,7 +52,7 @@ class UntypedTrapLabel {
5252
size_t strSize() const {
5353
if (id_ == 0) return 2; // #0
5454
// Number of hex digits is ceil(bit_width(id) / 4), but C++ integer division can only do floor.
55-
return /* # */ 1 + /* hex digits */ 1 + (absl::bit_width(id_) - 1) / 4;
55+
return /* # */ 1 + /* hex digits */ 1 + (std::bit_width(id_) - 1) / 4;
5656
}
5757

5858
friend bool operator!=(UntypedTrapLabel lhs, UntypedTrapLabel rhs) { return lhs.id_ != rhs.id_; }

swift/logging/SwiftLogging.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@
5555
#define DIAGNOSE_CRITICAL(ID, ...) DIAGNOSE_WITH_LEVEL(critical, ID, __VA_ARGS__)
5656

5757
#define CODEQL_DIAGNOSTIC_LOG_FORMAT_PREFIX "[{}] "
58-
// TODO(C++20) replace non-standard , ##__VA_ARGS__ with __VA_OPT__(,) __VA_ARGS__
5958
#define DIAGNOSE_WITH_LEVEL(LEVEL, ID, FORMAT, ...) \
6059
do { \
6160
auto _now = ::binlog::clockNow(); \
6261
const ::codeql::SwiftDiagnostic& _id = ID; \
6362
::codeql::Log::diagnose(_id, std::chrono::nanoseconds{_now}, \
64-
fmt::format(FORMAT, ##__VA_ARGS__)); \
63+
fmt::format(FORMAT __VA_OPT__(, ) __VA_ARGS__)); \
6564
LOG_WITH_LEVEL_AND_TIME(LEVEL, _now, CODEQL_DIAGNOSTIC_LOG_FORMAT_PREFIX FORMAT, \
66-
_id.abbreviation(), ##__VA_ARGS__); \
65+
_id.abbreviation() __VA_OPT__(, ) __VA_ARGS__); \
6766
} while (false)
6867

6968
// avoid calling into binlog's original macros

0 commit comments

Comments
 (0)