forked from Checkmk/checkmk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.clang-tidy
100 lines (100 loc) · 9.26 KB
/
.clang-tidy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
# Classification of the excludes:
#
# * unclear, need to figure out if we want that:
# * cert-err58-cpp ("construction of 'foo' with static storage duration may throw an exception that cannot be caught")
# * cppcoreguidelines-pro-bounds-array-to-pointer-decay ("do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead")
# * cppcoreguidelines-pro-bounds-constant-array-index ("do not use array subscript when the index is not an integer constant expression; use gsl::at() instead")
# * cppcoreguidelines-pro-bounds-pointer-arithmetic ("do not use pointer arithmetic")
# * google-runtime-int ("consider replacing 'unsigned long' with 'uint64'")
# * hicpp-no-array-decay ("do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead")
# * readability-identifier-length ("Parameter name 'FOO' is too short, expected at least BAR characters")
#
# * undesirable checks:
# * abseil-string-find-str-contains ("'find' called with a string literal of a single character; consider using...")
# * altera-id-dependent-backward-branch ("backward branch (while loop) is ID-dependent due to variable reference to 'foo' and may cause performance degradation")
# * altera-struct-pack-align ("accessing fields in struct 'FOO' is inefficient...")
# * altera-unroll-loops ("kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive")
# * cppcoreguidelines-pro-type-static-cast-downcast ("do not use static_cast to downcast from a base to a derived class; use dynamic_cast instead")
# * fuchsia-default-arguments ("calling a function that uses a default argument is disallowed")
# * fuchsia-default-arguments-calls: ("calling a function that uses a default argument is disallowed")
# * fuchsia-overloaded-operator ("cannot overload 'operatorFOO'")
# * fuchsia-statically-constructed-objects ("static objects are disallowed; if possible, use a constexpr constructor instead")
# * google-runtime-references ("non-const reference parameter 'foo', make it const or use a pointer")
# * hicpp-no-assembler ("do not use inline assembler in safety-critical code") triggered by ntohs/htons
# * llvm-include-order ("#includes are not sorted properly")
# * llvmlibc-callee-namespace ("'foo' must resolve to a function declared within the '__llvm_libc' namespace")
# * llvmlibc-implementation-in-namespace ("declaration must be declared within the '__llvm_libc' namespace")
# * llvmlibc-restrict-system-libc-headers ("system include foo not allowed")
# * modernize-use-trailing-return-type ("use a trailing return type for this function")
#
# * desirable checks, but hard to fix currently:
# * android-cloexec-fopen ("use 'fopen' mode 'e' to set O_CLOEXEC") Ancient CentOS 5 doesn't have O_CLOEXEC
# * android-cloexec-open ("'open' should use O_CLOEXEC where possible") Ancient CentOS 5 doesn't have O_CLOEXEC
# * android-cloexec-pipe ("prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes")
# * bugprone-easily-swappable-parameters ("2 adjacent parameters of 'foo' of similar type ('bar') are easily swapped by mistake")
# * cert-env33-c ("calling 'system' uses a command processor")
# * cert-err34-c ("'atoi' used to convert a string to an integer value, but function will not report conversion errors; consider using 'strtol' instead")
# * cppcoreguidelines-non-private-member-variables-in-classes: alias of misc-non-private-member-variables-in-classes
# * cppcoreguidelines-owning-memory ("deleting a pointer through a type that is not marked 'gsl::owner<>'; consider using a smart pointer instead") We won't fix this for 1.5.0
# * cppcoreguidelines-prefer-member-initializer ("'foo' should be initialized in a member initializer of the constructor")
# * cppcoreguidelines-pro-type-member-init ("uninitialized record type: 'foo'")
# * cppcoreguidelines-pro-type-reinterpret-cast ("do not use reinterpret_cast")
# * cppcoreguidelines-pro-type-vararg ("do not call c-style vararg functions")
# * hicpp-member-init: alias for cppcoreguidelines-pro-type-member-init
# * hicpp-signed-bitwise ("use of a signed integer operand with a binary bitwise operator")
# * hicpp-vararg ("do not call c-style vararg functions")
# * llvm-header-guard ("header guard does not follow preferred style") tricky to get right with the current bear/clang-tidy/symlink situation
# * misc-non-private-member-variables-in-classes ("Member variable'foo' has public visibility")
#
# * desirable checks, but some places need to be suppressed:
# * cppcoreguidelines-pro-type-const-cast ("do not use const_cast")
# * cppcoreguidelines-pro-type-union-access ("do not access members of unions; use (boost::)variant instead")
# * modernize-use-bool-literals ("converting integer literal to bool, use bool literal instead") Incorrectly triggered by e.g. FD_ZERO
#
# * temporarily disabled:
# * clang-analyzer-optin.performance.Padding
# * cppcoreguidelines-avoid-c-arrays / hicpp-avoid-c-arrays / modernize-avoid-c-arrays
# * cppcoreguidelines-avoid-magic-numbers / readability-magic-numbers
# * cppcoreguidelines-special-member-functions / hicpp-special-member-functions
# * modernize-use-default-member-init
#
# * bug in toolchain/clang-tidy:
# * clang-analyzer-cplusplus.NewDeleteLeaks ("Potential leak of memory pointed to by field '_M_head_impl'") See https://bugs.llvm.org/show_bug.cgi?id=38176 ("clang-analyzer-cplusplus.NewDeleteLeaks false positive in C++17 mode only")
# * fuchsia-trailing-return: Doesn't really help that much, but gives various false positives.
#
# * TODO (for clangd-12): Figure out the details for the following checks:
# * bugprone-narrowing-conversions
# * bugprone-reserved-identifier
# * cert-dcl37-c
# * cert-dcl51-cpp
# * concurrency-mt-unsafe
# * cppcoreguidelines-narrowing-conversions
# * misc-no-recursion
# * performance-no-int-to-ptr
#
Checks: '*,-abseil-string-find-str-contains,-altera-id-dependent-backward-branch,-altera-struct-pack-align,-altera-unroll-loops,-android-cloexec-fopen,-android-cloexec-open,-android-cloexec-pipe,-bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-bugprone-reserved-identifier,-cert-dcl37-c,-cert-dcl51-cpp,-cert-env33-c,-cert-err34-c,-cert-err58-cpp,-clang-analyzer-alpha*,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-optin.performance.Padding,-concurrency-mt-unsafe,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-owning-memory,-cppcoreguidelines-prefer-member-initializer,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-static-cast-downcast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-special-member-functions,-fuchsia-default-arguments,-fuchsia-default-arguments-calls,-fuchsia-overloaded-operator,-fuchsia-statically-constructed-objects,-fuchsia-trailing-return,-google-runtime-int,-google-runtime-references,-hicpp-avoid-c-arrays,-hicpp-member-init,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-signed-bitwise,-hicpp-special-member-functions,-hicpp-vararg,-llvm-header-guard,-llvm-include-order,-llvmlibc-callee-namespace,-llvmlibc-implementation-in-namespace,-llvmlibc-restrict-system-libc-headers,-misc-no-recursion,-misc-non-private-member-variables-in-classes,-modernize-avoid-c-arrays,-modernize-use-bool-literals,-modernize-use-default-member-init,-modernize-use-trailing-return-type,-performance-no-int-to-ptr,-readability-identifier-length,-readability-magic-numbers'
WarningsAsErrors: '*'
# Alas, readability-identifier-naming still has a few bugs. Nevertheless, we already configure a few things here...
CheckOptions:
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '1'
# - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
# value: '1'
# - key: readability-identifier-naming.MemberCase
# value: 'lower_case'
# - key: readability-identifier-naming.ProtectedMemberSuffix
# value: '_'
# - key: readability-identifier-naming.PrivateMemberSuffix
# value: '_'
# - key: readability-identifier-naming.VariableCase
# value: 'lower_case'
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
value: 'int8_t'
# TODO: We need a very high threshold here, especially for unit tests (default is 25),
# lowering this would be good. But does IgnoreMacros really work? I'm not so sure...
- key: readability-function-cognitive-complexity.Threshold
value: '188'
- key: readability-function-cognitive-complexity.IgnoreMacros
value: 'true'
...