2022-08-26 13:54:57 +00:00
# To run clang-tidy from CMake, build ClickHouse with -DENABLE_CLANG_TIDY=1. To show all warnings, it is
# recommended to pass "-k0" to Ninja.
2022-10-04 15:29:33 +00:00
# Enable all checks + disable selected checks. Feel free to remove disabled checks from below list if
2022-05-19 15:39:53 +00:00
# a) the new check is not controversial (this includes many checks in readability-* and google-*) or
# b) too noisy (checks with > 100 new warnings are considered noisy, this includes e.g. cppcoreguidelines-*).
2022-08-26 13:54:57 +00:00
2024-03-14 12:16:33 +00:00
HeaderFilterRegex: '^.*/(base|src|programs|utils)/.*(h|hpp)$'
2022-08-26 13:54:57 +00:00
2024-03-11 10:56:26 +00:00
Checks: [
'*',
'-abseil-*',
'-altera-*',
'-android-*',
2024-10-15 16:24:06 +00:00
'-boost-use-ranges',
'-modernize-use-ranges',
2024-03-11 10:56:26 +00:00
'-bugprone-assignment-in-if-condition',
'-bugprone-branch-clone',
'-bugprone-easily-swappable-parameters',
'-bugprone-exception-escape',
2024-03-18 20:34:15 +00:00
'-bugprone-forward-declaration-namespace',
2024-03-11 10:56:26 +00:00
'-bugprone-implicit-widening-of-multiplication-result',
2024-05-19 15:45:23 +00:00
'-bugprone-multi-level-implicit-pointer-conversion',
2024-03-11 10:56:26 +00:00
'-bugprone-narrowing-conversions',
'-bugprone-not-null-terminated-result',
'-bugprone-unchecked-optional-access',
2024-07-17 00:08:37 +00:00
'-bugprone-crtp-constructor-accessibility',
2024-03-11 10:56:26 +00:00
'-cert-dcl16-c',
'-cert-dcl37-c',
'-cert-dcl51-cpp',
'-cert-err58-cpp',
'-cert-msc32-c',
'-cert-msc51-cpp',
'-cert-oop54-cpp',
'-cert-oop57-cpp',
2024-07-17 00:08:37 +00:00
'-cert-err33-c', # Misreports on clang-19: it warns about all functions containing 'remove' in the name, not only about the standard library.
2024-03-11 10:56:26 +00:00
2024-03-14 12:16:33 +00:00
'-clang-analyzer-optin.performance.Padding',
2024-10-15 16:24:06 +00:00
'-clang-analyzer-cplusplus.PlacementNew',
2024-03-11 10:56:26 +00:00
'-clang-analyzer-unix.Malloc',
'-cppcoreguidelines-*', # impractical in a codebase as large as ClickHouse, also slow
'-darwin-*',
'-fuchsia-*',
'-google-build-using-namespace',
'-google-readability-braces-around-statements',
'-google-readability-casting',
'-google-readability-function-size',
'-google-readability-namespace-comments',
'-google-readability-todo',
'-hicpp-avoid-c-arrays',
'-hicpp-avoid-goto',
'-hicpp-braces-around-statements',
'-hicpp-explicit-conversions',
'-hicpp-function-size',
'-hicpp-member-init',
'-hicpp-move-const-arg',
'-hicpp-multiway-paths-covered',
'-hicpp-named-parameter',
'-hicpp-no-array-decay',
'-hicpp-no-assembler',
'-hicpp-no-malloc',
'-hicpp-signed-bitwise',
'-hicpp-special-member-functions',
'-hicpp-uppercase-literal-suffix',
'-hicpp-use-auto',
'-hicpp-use-emplace',
'-hicpp-vararg',
'-linuxkernel-*',
'-llvm-*',
'-llvmlibc-*',
'-openmp-*',
'-misc-const-correctness',
'-misc-include-cleaner', # useful but far too many occurrences
'-misc-no-recursion',
'-misc-non-private-member-variables-in-classes',
'-misc-confusable-identifiers', # useful but slooo
'-misc-use-anonymous-namespace',
2024-10-15 16:24:06 +00:00
'-misc-use-internal-linkage',
2024-03-11 10:56:26 +00:00
'-modernize-avoid-c-arrays',
'-modernize-concat-nested-namespaces',
'-modernize-macro-to-enum',
'-modernize-pass-by-value',
'-modernize-return-braced-init-list',
'-modernize-use-auto',
2024-05-21 05:15:35 +00:00
'-modernize-use-constraints', # This is a good check, but clang-tidy crashes, see https://github.com/llvm/llvm-project/issues/91872
2024-03-11 10:56:26 +00:00
'-modernize-use-default-member-init',
'-modernize-use-emplace',
'-modernize-use-nodiscard',
'-modernize-use-trailing-return-type',
2024-07-17 00:08:37 +00:00
'-modernize-use-designated-initializers',
2024-03-11 10:56:26 +00:00
2024-05-19 15:45:23 +00:00
'-performance-enum-size',
2024-03-11 10:56:26 +00:00
'-performance-inefficient-string-concatenation',
'-performance-no-int-to-ptr',
'-performance-avoid-endl',
'-performance-unnecessary-value-param',
'-portability-simd-intrinsics',
2024-05-19 15:45:23 +00:00
'-readability-avoid-nested-conditional-operator',
2024-03-11 10:56:26 +00:00
'-readability-avoid-unconditional-preprocessor-if',
'-readability-braces-around-statements',
'-readability-convert-member-functions-to-static',
'-readability-else-after-return',
'-readability-function-cognitive-complexity',
'-readability-function-size',
'-readability-identifier-length',
'-readability-identifier-naming', # useful but too slow
'-readability-implicit-bool-conversion',
'-readability-isolate-declaration',
'-readability-magic-numbers',
'-readability-named-parameter',
'-readability-redundant-declaration',
2024-05-21 05:15:35 +00:00
'-readability-redundant-inline-specifier', # useful but incompatible with __attribute((always_inline))__ (aka. ALWAYS_INLINE, base/base/defines.h).
# ALWAYS_INLINE only has an effect if combined with `inline`: https://godbolt.org/z/Eefd74qdM
2024-05-19 17:53:06 +00:00
'-readability-redundant-member-init', # Useful but triggers another problem. Imagine a struct S with multiple String members. Structs are often instantiated via designated
# initializer S s{.s1 = [...], .s2 = [...], [...]}. In this case, compiler warning `missing-field-initializers` requires to specify all members which are not in-struct
# initialized (example: s1 in struct S { String s1; String s2{};}; is not in-struct initialized, therefore it must be specified at instantiation time). As explicitly
# specifying all members is tedious for large structs, `missing-field-initializers` makes programmers initialize as many members as possible in-struct. Clang-tidy
# warning `readability-redundant-member-init` does the opposite thing, both are not compatible with each other.
2024-03-11 10:56:26 +00:00
'-readability-simplify-boolean-expr',
'-readability-suspicious-call-argument',
'-readability-uppercase-literal-suffix',
'-readability-use-anyofallof',
2024-10-15 16:24:06 +00:00
'-readability-math-missing-parentheses',
2024-03-11 10:56:26 +00:00
2024-05-21 05:15:35 +00:00
'-zircon-*'
2024-03-11 10:56:26 +00:00
]
2022-05-04 17:24:02 +00:00
2020-03-08 20:17:49 +00:00
WarningsAsErrors: '*'
2020-03-23 02:12:31 +00:00
2023-09-21 10:54:09 +00:00
ExtraArgs:
# clang-tidy 17 started to complain (for unknown reasons) that various pragmas are unknown ("clang-diagnostic-unknown-pragmas").
# This is technically a compiler error, not a clang-tidy error. We could litter the code base with more pragmas that suppress
# this error but it is better to pass the following flag to the compiler:
- '-Wno-unknown-pragmas'
2023-09-21 18:39:02 +00:00
- '-Wno-unused-command-line-argument' # similar issue
2023-09-21 10:54:09 +00:00
2020-03-23 02:12:31 +00:00
CheckOptions:
2023-03-16 16:59:24 +00:00
readability-identifier-naming.ClassCase: CamelCase
2023-03-16 13:49:27 +00:00
readability-identifier-naming.EnumCase: CamelCase
readability-identifier-naming.LocalVariableCase: lower_case
readability-identifier-naming.StaticConstantCase: aNy_CasE
readability-identifier-naming.MemberCase: lower_case
readability-identifier-naming.PrivateMemberPrefix: ''
readability-identifier-naming.ProtectedMemberPrefix: ''
readability-identifier-naming.PublicMemberCase: lower_case
readability-identifier-naming.MethodCase: camelBack
readability-identifier-naming.PrivateMethodPrefix: ''
readability-identifier-naming.ProtectedMethodPrefix: ''
readability-identifier-naming.ParameterPackCase: lower_case
readability-identifier-naming.StructCase: CamelCase
readability-identifier-naming.TemplateTemplateParameterCase: CamelCase
2023-05-13 20:26:43 +00:00
readability-identifier-naming.TemplateParameterCase: lower_case
2023-03-16 13:49:27 +00:00
readability-identifier-naming.TypeTemplateParameterCase: CamelCase
readability-identifier-naming.TypedefCase: CamelCase
readability-identifier-naming.UnionCase: CamelCase
modernize-loop-convert.UseCxx20ReverseRanges: false
performance-move-const-arg.CheckTriviallyCopyableMove: false
# Workaround clang-tidy bug: https://github.com/llvm/llvm-project/issues/46097
readability-identifier-naming.TypeTemplateParameterIgnoredRegexp: expr-type
cppcoreguidelines-avoid-do-while.IgnoreMacros: true