mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Swift: Fix some C++20 todos.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <bit>
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "absl/numeric/bits.h"
|
||||
#include <binlog/binlog.hpp>
|
||||
#include <cmath>
|
||||
#include <charconv>
|
||||
@@ -52,7 +52,7 @@ class UntypedTrapLabel {
|
||||
size_t strSize() const {
|
||||
if (id_ == 0) return 2; // #0
|
||||
// Number of hex digits is ceil(bit_width(id) / 4), but C++ integer division can only do floor.
|
||||
return /* # */ 1 + /* hex digits */ 1 + (absl::bit_width(id_) - 1) / 4;
|
||||
return /* # */ 1 + /* hex digits */ 1 + (std::bit_width(id_) - 1) / 4;
|
||||
}
|
||||
|
||||
friend bool operator!=(UntypedTrapLabel lhs, UntypedTrapLabel rhs) { return lhs.id_ != rhs.id_; }
|
||||
|
||||
@@ -55,15 +55,14 @@
|
||||
#define DIAGNOSE_CRITICAL(ID, ...) DIAGNOSE_WITH_LEVEL(critical, ID, __VA_ARGS__)
|
||||
|
||||
#define CODEQL_DIAGNOSTIC_LOG_FORMAT_PREFIX "[{}] "
|
||||
// TODO(C++20) replace non-standard , ##__VA_ARGS__ with __VA_OPT__(,) __VA_ARGS__
|
||||
#define DIAGNOSE_WITH_LEVEL(LEVEL, ID, FORMAT, ...) \
|
||||
do { \
|
||||
auto _now = ::binlog::clockNow(); \
|
||||
const ::codeql::SwiftDiagnostic& _id = ID; \
|
||||
::codeql::Log::diagnose(_id, std::chrono::nanoseconds{_now}, \
|
||||
fmt::format(FORMAT, ##__VA_ARGS__)); \
|
||||
fmt::format(FORMAT __VA_OPT__(, ) __VA_ARGS__)); \
|
||||
LOG_WITH_LEVEL_AND_TIME(LEVEL, _now, CODEQL_DIAGNOSTIC_LOG_FORMAT_PREFIX FORMAT, \
|
||||
_id.abbreviation(), ##__VA_ARGS__); \
|
||||
_id.abbreviation() __VA_OPT__(, ) __VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
// avoid calling into binlog's original macros
|
||||
|
||||
Reference in New Issue
Block a user