Skip to content

Commit f5137dd

Browse files
committed
More clang-tidy fixes
1 parent 50c51c2 commit f5137dd

File tree

22 files changed

+49
-37
lines changed

22 files changed

+49
-37
lines changed

.clang-tidy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# a) the new check is not controversial (this includes many checks in readability-* and google-*) or
66
# b) too noisy (checks with > 100 new warnings are considered noisy, this includes e.g. cppcoreguidelines-*).
77

8+
# TODO: Once clang(-tidy) 17 is the minimum, we can convert this list to YAML
9+
# See https://releases.llvm.org/17.0.1/tools/clang/tools/extra/docs/ReleaseNotes.html#improvements-to-clang-tidy
10+
811
# TODO Let clang-tidy check headers in further directories
912
# --> HeaderFilterRegex: '^.*/(src|base|programs|utils)/.*(h|hpp)$'
1013
HeaderFilterRegex: '^.*/(base)/.*(h|hpp)$'
@@ -25,6 +28,7 @@ Checks: '*,
2528
-bugprone-not-null-terminated-result,
2629
-bugprone-reserved-identifier, # useful but too slow, TODO retry when https://reviews.llvm.org/rG1c282052624f9d0bd273bde0b47b30c96699c6c7 is merged
2730
-bugprone-unchecked-optional-access,
31+
-bugprone-*, -- category temporarily disabled because some check(s) in it are slow
2832
2933
-cert-dcl16-c,
3034
-cert-dcl37-c,
@@ -39,6 +43,7 @@ Checks: '*,
3943
-clang-analyzer-optin.portability.UnixAPI,
4044
-clang-analyzer-security.insecureAPI.bzero,
4145
-clang-analyzer-security.insecureAPI.strcpy,
46+
-clang-analyzer-*, -- category temporarily disabled because some check(s) in it are slow
4247
4348
-cppcoreguidelines-avoid-c-arrays,
4449
-cppcoreguidelines-avoid-const-or-ref-data-members,
@@ -67,6 +72,7 @@ Checks: '*,
6772
-cppcoreguidelines-pro-type-vararg,
6873
-cppcoreguidelines-slicing,
6974
-cppcoreguidelines-special-member-functions,
75+
-cppcoreguidelines-*, -- category temporarily disabled because some check(s) in it are slow
7076
7177
-darwin-*,
7278
@@ -128,10 +134,12 @@ Checks: '*,
128134
129135
-performance-inefficient-string-concatenation,
130136
-performance-no-int-to-ptr,
137+
-performance-avoid-endl,
131138
-performance-unnecessary-value-param,
132139
133140
-portability-simd-intrinsics,
134141
142+
-readability-avoid-unconditional-preprocessor-if,
135143
-readability-braces-around-statements,
136144
-readability-convert-member-functions-to-static,
137145
-readability-else-after-return,
@@ -155,6 +163,12 @@ Checks: '*,
155163

156164
WarningsAsErrors: '*'
157165

166+
ExtraArgs:
167+
# clang-tidy 17 started to complain (for unknown reasons) that various pragmas are unknown ("clang-diagnostic-unknown-pragmas").
168+
# This is technically a compiler error, not a clang-tidy error. We could litter the code base with more pragmas that suppress
169+
# this error but it is better to pass the following flag to the compiler:
170+
- '-Wno-unknown-pragmas'
171+
158172
CheckOptions:
159173
readability-identifier-naming.ClassCase: CamelCase
160174
readability-identifier-naming.EnumCase: CamelCase

base/pcg-random/pcg_extras.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ auto bounded_rand(RngType& rng, typename RngType::result_type upper_bound)
463463
}
464464

465465
template <typename Iter, typename RandType>
466-
void shuffle(Iter from, Iter to, RandType&& rng)
466+
void shuffle(Iter from, Iter to, RandType&& rng) // NOLINT(cppcoreguidelines-missing-std-forward)
467467
{
468468
typedef typename std::iterator_traits<Iter>::difference_type delta_t;
469469
typedef typename std::remove_reference<RandType>::type::result_type result_t;

src/Bridge/IBridge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void IBridge::initialize(Application & self)
140140
throw Poco::OpenFileException("Cannot attach stdout to " + stdout_path);
141141

142142
/// Disable buffering for stdout.
143-
setbuf(stdout, nullptr);
143+
setbuf(stdout, nullptr); // NOLINT(cert-msc24-c,cert-msc33-c)
144144
}
145145
const auto stderr_path = config().getString("logger.stderr", "");
146146
if (!stderr_path.empty())
@@ -149,7 +149,7 @@ void IBridge::initialize(Application & self)
149149
throw Poco::OpenFileException("Cannot attach stderr to " + stderr_path);
150150

151151
/// Disable buffering for stderr.
152-
setbuf(stderr, nullptr);
152+
setbuf(stderr, nullptr); // NOLINT(cert-msc24-c,cert-msc33-c)
153153
}
154154

155155
buildLoggers(config(), logger(), self.commandName());

src/Common/DNSResolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ static String cacheElemToString(const Poco::Net::IPAddress & addr) { return addr
310310

311311
template <typename UpdateF, typename ElemsT>
312312
bool DNSResolver::updateCacheImpl(
313-
UpdateF && update_func,
314-
ElemsT && elems,
313+
UpdateF && update_func, // NOLINT(cppcoreguidelines-missing-std-forward)
314+
ElemsT && elems, // NOLINT(cppcoreguidelines-missing-std-forward)
315315
UInt32 max_consecutive_failures,
316316
FormatStringHelper<String> notfound_log_msg,
317317
FormatStringHelper<String> dropped_log_msg)

src/Compression/tests/gtest_compressionCodec.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ using namespace DB;
3636
namespace
3737
{
3838

39-
template <class T> using is_pod = std::is_trivial<std::is_standard_layout<T>>;
40-
template <class T> inline constexpr bool is_pod_v = is_pod<T>::value;
41-
39+
template <class T> inline constexpr bool is_pod_v = std::is_trivial_v<std::is_standard_layout<T>>;
4240

4341
template <typename T>
4442
struct AsHexStringHelper

src/Core/SettingsFields.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ constexpr auto getEnumValues()
429429
if (it != map.end()) \
430430
return it->second; \
431431
throw Exception(ERROR_CODE_FOR_UNEXPECTED_NAME, \
432-
"Unexpected value of " #NEW_NAME ":{}", std::to_string(std::underlying_type<EnumType>::type(value))); \
432+
"Unexpected value of " #NEW_NAME ":{}", std::to_string(std::underlying_type_t<EnumType>(value))); \
433433
} \
434434
\
435435
typename SettingField##NEW_NAME::EnumType SettingField##NEW_NAME##Traits::fromString(std::string_view str) \

src/Daemon/BaseDaemon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ void BaseDaemon::initialize(Application & self)
843843
throw Poco::OpenFileException("Cannot attach stderr to " + stderr_path);
844844

845845
/// Disable buffering for stderr
846-
setbuf(stderr, nullptr);
846+
setbuf(stderr, nullptr); // NOLINT(cert-msc24-c,cert-msc33-c)
847847
}
848848

849849
if ((!log_path.empty() && is_daemon) || config().has("logger.stdout"))

src/DataTypes/DataTypeLowCardinality.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ MutableColumnUniquePtr DataTypeLowCardinality::createColumnUnique(const IDataTyp
111111
{
112112
auto creator = [&](auto x)
113113
{
114-
using ColumnType = typename std::remove_pointer<decltype(x)>::type;
114+
using ColumnType = typename std::remove_pointer_t<decltype(x)>;
115115
return ColumnUnique<ColumnType>::create(keys_type);
116116
};
117117
return createColumnUniqueImpl(keys_type, creator);
@@ -121,7 +121,7 @@ MutableColumnUniquePtr DataTypeLowCardinality::createColumnUnique(const IDataTyp
121121
{
122122
auto creator = [&](auto x)
123123
{
124-
using ColumnType = typename std::remove_pointer<decltype(x)>::type;
124+
using ColumnType = typename std::remove_pointer_t<decltype(x)>;
125125
return ColumnUnique<ColumnType>::create(std::move(keys), keys_type.isNullable());
126126
};
127127
return createColumnUniqueImpl(keys_type, creator);

src/Functions/GatherUtils/ends_with.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct ArrayEndsWithSelectArraySourcePair : public ArraySourcePairSelector<Array
1515
bool is_second_const, bool is_second_nullable, SecondSource && second,
1616
ColumnUInt8 & result)
1717
{
18-
using SourceType = typename std::decay<SecondSource>::type;
18+
using SourceType = typename std::decay_t<SecondSource>;
1919

2020
if (is_second_nullable)
2121
{
@@ -40,7 +40,7 @@ struct ArrayEndsWithSelectArraySourcePair : public ArraySourcePairSelector<Array
4040
bool is_second_const, bool is_second_nullable, SecondSource && second,
4141
ColumnUInt8 & result)
4242
{
43-
using SourceType = typename std::decay<FirstSource>::type;
43+
using SourceType = typename std::decay_t<FirstSource>;
4444

4545
if (is_first_nullable)
4646
{

src/Functions/GatherUtils/has_all.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct ArrayHasAllSelectArraySourcePair : public ArraySourcePairSelector<ArrayHa
1515
bool is_second_const, bool is_second_nullable, SecondSource && second,
1616
ColumnUInt8 & result)
1717
{
18-
using SourceType = typename std::decay<SecondSource>::type;
18+
using SourceType = typename std::decay_t<SecondSource>;
1919

2020
if (is_second_nullable)
2121
{
@@ -40,7 +40,7 @@ struct ArrayHasAllSelectArraySourcePair : public ArraySourcePairSelector<ArrayHa
4040
bool is_second_const, bool is_second_nullable, SecondSource && second,
4141
ColumnUInt8 & result)
4242
{
43-
using SourceType = typename std::decay<FirstSource>::type;
43+
using SourceType = typename std::decay_t<FirstSource>;
4444

4545
if (is_first_nullable)
4646
{

0 commit comments

Comments
 (0)