From 3b18eb4f17e5c85afff8d2a6f07ec77c0ab98129 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Wed, 28 Feb 2024 22:47:34 +0000 Subject: [PATCH 1/5] Fix clang-tidy in some headers --- .clang-tidy | 2 +- programs/copier/Internals.h | 2 +- programs/odbc-bridge/ODBCPooledConnectionFactory.h | 3 +-- programs/server/Server.cpp | 2 +- src/Backups/registerBackupEngineS3.cpp | 6 ++---- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3903911a277..0dacf813c7e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,7 +10,7 @@ # TODO Let clang-tidy check headers in further directories # --> HeaderFilterRegex: '^.*/(src|base|programs|utils)/.*(h|hpp)$' -HeaderFilterRegex: '^.*/(base)/.*(h|hpp)$' +HeaderFilterRegex: '^.*/(base|programs|utils)/.*(h|hpp)$' Checks: '*, -abseil-*, diff --git a/programs/copier/Internals.h b/programs/copier/Internals.h index 48f4b0fab09..27fedd5d9e8 100644 --- a/programs/copier/Internals.h +++ b/programs/copier/Internals.h @@ -102,7 +102,7 @@ struct TaskStateWithOwner return TaskStateWithOwner(state, owner).toString(); } - String toString() + String toString() const { WriteBufferFromOwnString wb; wb << static_cast(state) << "\n" << escape << owner; diff --git a/programs/odbc-bridge/ODBCPooledConnectionFactory.h b/programs/odbc-bridge/ODBCPooledConnectionFactory.h index b70e45f2b9d..c4e3d4c12c6 100644 --- a/programs/odbc-bridge/ODBCPooledConnectionFactory.h +++ b/programs/odbc-bridge/ODBCPooledConnectionFactory.h @@ -40,7 +40,6 @@ public: explicit ConnectionHolder(const String & connection_string_) : pool(nullptr) - , connection() , connection_string(connection_string_) { updateConnection(); @@ -143,7 +142,7 @@ public: { std::lock_guard lock(mutex); - if (!factory.count(connection_string)) + if (!factory.contains(connection_string)) factory.emplace(std::make_pair(connection_string, std::make_shared(pool_size))); auto & pool = factory[connection_string]; diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 6dc33042a05..eb38c7e2ff5 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -184,7 +184,7 @@ static bool jemallocOptionEnabled(const char *name) return value; } #else -static bool jemallocOptionEnabled(const char *) { return 0; } +static bool jemallocOptionEnabled(const char *) { return false; } #endif int mainEntryClickHouseServer(int argc, char ** argv) diff --git a/src/Backups/registerBackupEngineS3.cpp b/src/Backups/registerBackupEngineS3.cpp index 86941040021..fed5c6b4d22 100644 --- a/src/Backups/registerBackupEngineS3.cpp +++ b/src/Backups/registerBackupEngineS3.cpp @@ -15,8 +15,6 @@ namespace DB { -namespace fs = std::filesystem; - namespace ErrorCodes { extern const int BAD_ARGUMENTS; @@ -65,13 +63,13 @@ void registerBackupEngineS3(BackupFactory & factory) secret_access_key = config.getString(config_prefix + ".secret_access_key", ""); if (config.has(config_prefix + ".filename")) - s3_uri = fs::path(s3_uri) / config.getString(config_prefix + ".filename"); + s3_uri = std::filesystem::path(s3_uri) / config.getString(config_prefix + ".filename"); if (args.size() > 1) throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, "Backup S3 requires 1 or 2 arguments: named_collection, [filename]"); if (args.size() == 1) - s3_uri = fs::path(s3_uri) / args[0].safeGet(); + s3_uri = std::filesystem::path(s3_uri) / args[0].safeGet(); } else { From 0b4622ebf640ffb4d31a97d39ec4034007528c31 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Thu, 29 Feb 2024 09:45:08 +0000 Subject: [PATCH 2/5] Add more suppressions for utils --- programs/copier/ZooKeeperStaff.h | 2 +- src/Common/LoggingFormatStringHelpers.h | 8 ++++---- utils/memcpy-bench/FastMemcpy.h | 6 ++++-- utils/memcpy-bench/FastMemcpy_Avx.h | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/programs/copier/ZooKeeperStaff.h b/programs/copier/ZooKeeperStaff.h index bbdec230d2d..c15db73f060 100644 --- a/programs/copier/ZooKeeperStaff.h +++ b/programs/copier/ZooKeeperStaff.h @@ -180,7 +180,7 @@ public: auto logger = getLogger("ClusterCopier"); if (rsp.error == Coordination::Error::ZOK) { - switch (rsp.type) + switch (rsp.type) /// NOLINT(bugprone-switch-missing-default-case) { case Coordination::CREATED: LOG_DEBUG(logger, "CleanStateClock change: CREATED, at {}", rsp.path); diff --git a/src/Common/LoggingFormatStringHelpers.h b/src/Common/LoggingFormatStringHelpers.h index b0f0a5cd716..c60c74ee663 100644 --- a/src/Common/LoggingFormatStringHelpers.h +++ b/src/Common/LoggingFormatStringHelpers.h @@ -26,7 +26,7 @@ struct FormatStringHelperImpl formatStringCheckArgsNumImpl(message_format_string, sizeof...(Args)); } template - FormatStringHelperImpl(fmt::basic_runtime && str) : message_format_string(), fmt_str(std::forward>(str)) {} + FormatStringHelperImpl(fmt::basic_runtime && str) : message_format_string(), fmt_str(std::forward>(str)) {} /// NOLINT PreformattedMessage format(Args && ...args) const; }; @@ -43,9 +43,9 @@ struct PreformattedMessage template static PreformattedMessage create(FormatStringHelper fmt, Args &&... args); - operator const std::string & () const { return text; } - operator std::string () && { return std::move(text); } - operator fmt::format_string<> () const { UNREACHABLE(); } + operator const std::string & () const { return text; } /// NOLINT + operator std::string () && { return std::move(text); } /// NOLINT + operator fmt::format_string<> () const { UNREACHABLE(); } /// NOLINT void apply(std::string & out_text, std::string_view & out_format_string) const & { diff --git a/utils/memcpy-bench/FastMemcpy.h b/utils/memcpy-bench/FastMemcpy.h index 85d09c5f53e..e2ac73a1b63 100644 --- a/utils/memcpy-bench/FastMemcpy.h +++ b/utils/memcpy-bench/FastMemcpy.h @@ -33,9 +33,11 @@ #endif #endif +/// NOLINTBEGIN(modernize-use-using) typedef __attribute__((__aligned__(1))) uint16_t uint16_unaligned_t; typedef __attribute__((__aligned__(1))) uint32_t uint32_unaligned_t; typedef __attribute__((__aligned__(1))) uint64_t uint64_unaligned_t; +/// NOLINTEND(modernize-use-using) //--------------------------------------------------------------------- // fast copy for different sizes @@ -98,7 +100,7 @@ __attribute__((__no_sanitize__("undefined"))) inline void *memcpy_tiny(void * __ unsigned char *dd = ((unsigned char*)dst) + size; const unsigned char *ss = ((const unsigned char*)src) + size; - switch (size) + switch (size) /// NOLINT(bugprone-switch-missing-default-case) { case 64: memcpy_sse2_64(dd - 64, ss - 64); @@ -652,7 +654,7 @@ __attribute__((__no_sanitize__("undefined"))) inline void *memcpy_tiny(void * __ //--------------------------------------------------------------------- // main routine //--------------------------------------------------------------------- -void* memcpy_fast_sse(void * __restrict destination, const void * __restrict source, size_t size) +inline void* memcpy_fast_sse(void * __restrict destination, const void * __restrict source, size_t size) { unsigned char *dst = (unsigned char*)destination; const unsigned char *src = (const unsigned char*)source; diff --git a/utils/memcpy-bench/FastMemcpy_Avx.h b/utils/memcpy-bench/FastMemcpy_Avx.h index ee7d4e19536..3271e10d237 100644 --- a/utils/memcpy-bench/FastMemcpy_Avx.h +++ b/utils/memcpy-bench/FastMemcpy_Avx.h @@ -103,7 +103,7 @@ static INLINE void *memcpy_tiny_avx(void * __restrict dst, const void * __restri unsigned char *dd = reinterpret_cast(dst) + size; const unsigned char *ss = reinterpret_cast(src) + size; - switch (size) + switch (size) /// NOLINT(bugprone-switch-missing-default-case) { case 128: memcpy_avx_128(dd - 128, ss - 128); [[fallthrough]]; case 0: break; @@ -371,7 +371,7 @@ static INLINE void *memcpy_tiny_avx(void * __restrict dst, const void * __restri //--------------------------------------------------------------------- // main routine //--------------------------------------------------------------------- -void* memcpy_fast_avx(void * __restrict destination, const void * __restrict source, size_t size) +inline void* memcpy_fast_avx(void * __restrict destination, const void * __restrict source, size_t size) { unsigned char *dst = reinterpret_cast(destination); const unsigned char *src = reinterpret_cast(source); From e27472c09dc94e1ddaa8e5972d74ffe3d3e07eb1 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Thu, 29 Feb 2024 09:47:44 +0000 Subject: [PATCH 3/5] Correct changes in LoggingFormatStringHelpers.h --- src/Common/LoggingFormatStringHelpers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Common/LoggingFormatStringHelpers.h b/src/Common/LoggingFormatStringHelpers.h index c60c74ee663..73bf53a955b 100644 --- a/src/Common/LoggingFormatStringHelpers.h +++ b/src/Common/LoggingFormatStringHelpers.h @@ -26,7 +26,7 @@ struct FormatStringHelperImpl formatStringCheckArgsNumImpl(message_format_string, sizeof...(Args)); } template - FormatStringHelperImpl(fmt::basic_runtime && str) : message_format_string(), fmt_str(std::forward>(str)) {} /// NOLINT + explicit FormatStringHelperImpl(fmt::basic_runtime && str) : fmt_str(std::forward>(str)) {} PreformattedMessage format(Args && ...args) const; }; @@ -43,9 +43,9 @@ struct PreformattedMessage template static PreformattedMessage create(FormatStringHelper fmt, Args &&... args); - operator const std::string & () const { return text; } /// NOLINT - operator std::string () && { return std::move(text); } /// NOLINT - operator fmt::format_string<> () const { UNREACHABLE(); } /// NOLINT + explicit operator const std::string & () const { return text; } + explicit operator std::string () && { return std::move(text); } + explicit operator fmt::format_string<> () const { UNREACHABLE(); } void apply(std::string & out_text, std::string_view & out_format_string) const & { From 117764e53cc740522ff5cfbd2a6aec74ad4a53df Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Thu, 29 Feb 2024 11:33:26 +0000 Subject: [PATCH 4/5] Revert "Correct changes in LoggingFormatStringHelpers.h" This reverts commit e27472c09dc94e1ddaa8e5972d74ffe3d3e07eb1. --- src/Common/LoggingFormatStringHelpers.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Common/LoggingFormatStringHelpers.h b/src/Common/LoggingFormatStringHelpers.h index 73bf53a955b..c60c74ee663 100644 --- a/src/Common/LoggingFormatStringHelpers.h +++ b/src/Common/LoggingFormatStringHelpers.h @@ -26,7 +26,7 @@ struct FormatStringHelperImpl formatStringCheckArgsNumImpl(message_format_string, sizeof...(Args)); } template - explicit FormatStringHelperImpl(fmt::basic_runtime && str) : fmt_str(std::forward>(str)) {} + FormatStringHelperImpl(fmt::basic_runtime && str) : message_format_string(), fmt_str(std::forward>(str)) {} /// NOLINT PreformattedMessage format(Args && ...args) const; }; @@ -43,9 +43,9 @@ struct PreformattedMessage template static PreformattedMessage create(FormatStringHelper fmt, Args &&... args); - explicit operator const std::string & () const { return text; } - explicit operator std::string () && { return std::move(text); } - explicit operator fmt::format_string<> () const { UNREACHABLE(); } + operator const std::string & () const { return text; } /// NOLINT + operator std::string () && { return std::move(text); } /// NOLINT + operator fmt::format_string<> () const { UNREACHABLE(); } /// NOLINT void apply(std::string & out_text, std::string_view & out_format_string) const & { From 845dcc95eca3e8664553c664f51432315f472d09 Mon Sep 17 00:00:00 2001 From: Robert Schulze Date: Fri, 1 Mar 2024 11:43:54 +0000 Subject: [PATCH 5/5] Fix build --- utils/memcpy-bench/FastMemcpy.h | 2 +- utils/memcpy-bench/FastMemcpy_Avx.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/memcpy-bench/FastMemcpy.h b/utils/memcpy-bench/FastMemcpy.h index e2ac73a1b63..650a6761771 100644 --- a/utils/memcpy-bench/FastMemcpy.h +++ b/utils/memcpy-bench/FastMemcpy.h @@ -654,7 +654,7 @@ __attribute__((__no_sanitize__("undefined"))) inline void *memcpy_tiny(void * __ //--------------------------------------------------------------------- // main routine //--------------------------------------------------------------------- -inline void* memcpy_fast_sse(void * __restrict destination, const void * __restrict source, size_t size) +void* memcpy_fast_sse(void * __restrict destination, const void * __restrict source, size_t size) /// NOLINT(misc-definitions-in-headers) { unsigned char *dst = (unsigned char*)destination; const unsigned char *src = (const unsigned char*)source; diff --git a/utils/memcpy-bench/FastMemcpy_Avx.h b/utils/memcpy-bench/FastMemcpy_Avx.h index 3271e10d237..aecf8abbe03 100644 --- a/utils/memcpy-bench/FastMemcpy_Avx.h +++ b/utils/memcpy-bench/FastMemcpy_Avx.h @@ -371,7 +371,7 @@ static INLINE void *memcpy_tiny_avx(void * __restrict dst, const void * __restri //--------------------------------------------------------------------- // main routine //--------------------------------------------------------------------- -inline void* memcpy_fast_avx(void * __restrict destination, const void * __restrict source, size_t size) +void* memcpy_fast_avx(void * __restrict destination, const void * __restrict source, size_t size) /// NOLINT(misc-definitions-in-headers) { unsigned char *dst = reinterpret_cast(destination); const unsigned char *src = reinterpret_cast(source);