[MemProf] Templatize CallStackRadixTreeBuilder (NFC) (#117014)
[llvm-project.git] / clang-tools-extra / clang-tidy / bugprone / BugproneTidyModule.cpp
blob33ac65e715ce811ad9b23c47b366654a1bd5b1cc
1 //===--- BugproneTidyModule.cpp - clang-tidy ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "../ClangTidy.h"
10 #include "../ClangTidyModule.h"
11 #include "../ClangTidyModuleRegistry.h"
12 #include "../cppcoreguidelines/NarrowingConversionsCheck.h"
13 #include "ArgumentCommentCheck.h"
14 #include "AssertSideEffectCheck.h"
15 #include "AssignmentInIfConditionCheck.h"
16 #include "BadSignalToKillThreadCheck.h"
17 #include "BitwisePointerCastCheck.h"
18 #include "BoolPointerImplicitConversionCheck.h"
19 #include "BranchCloneCheck.h"
20 #include "CastingThroughVoidCheck.h"
21 #include "ChainedComparisonCheck.h"
22 #include "ComparePointerToMemberVirtualFunctionCheck.h"
23 #include "CopyConstructorInitCheck.h"
24 #include "CrtpConstructorAccessibilityCheck.h"
25 #include "DanglingHandleCheck.h"
26 #include "DynamicStaticInitializersCheck.h"
27 #include "EasilySwappableParametersCheck.h"
28 #include "EmptyCatchCheck.h"
29 #include "ExceptionEscapeCheck.h"
30 #include "FoldInitTypeCheck.h"
31 #include "ForwardDeclarationNamespaceCheck.h"
32 #include "ForwardingReferenceOverloadCheck.h"
33 #include "ImplicitWideningOfMultiplicationResultCheck.h"
34 #include "InaccurateEraseCheck.h"
35 #include "IncDecInConditionsCheck.h"
36 #include "IncorrectEnableIfCheck.h"
37 #include "IncorrectRoundingsCheck.h"
38 #include "InfiniteLoopCheck.h"
39 #include "IntegerDivisionCheck.h"
40 #include "LambdaFunctionNameCheck.h"
41 #include "MacroParenthesesCheck.h"
42 #include "MacroRepeatedSideEffectsCheck.h"
43 #include "MisplacedOperatorInStrlenInAllocCheck.h"
44 #include "MisplacedPointerArithmeticInAllocCheck.h"
45 #include "MisplacedWideningCastCheck.h"
46 #include "MoveForwardingReferenceCheck.h"
47 #include "MultiLevelImplicitPointerConversionCheck.h"
48 #include "MultipleNewInOneExpressionCheck.h"
49 #include "MultipleStatementMacroCheck.h"
50 #include "NoEscapeCheck.h"
51 #include "NonZeroEnumToBoolConversionCheck.h"
52 #include "NondeterministicPointerIterationOrderCheck.h"
53 #include "NotNullTerminatedResultCheck.h"
54 #include "OptionalValueConversionCheck.h"
55 #include "ParentVirtualCallCheck.h"
56 #include "PointerArithmeticOnPolymorphicObjectCheck.h"
57 #include "PosixReturnCheck.h"
58 #include "RedundantBranchConditionCheck.h"
59 #include "ReservedIdentifierCheck.h"
60 #include "ReturnConstRefFromParameterCheck.h"
61 #include "SharedPtrArrayMismatchCheck.h"
62 #include "SignalHandlerCheck.h"
63 #include "SignedCharMisuseCheck.h"
64 #include "SizeofContainerCheck.h"
65 #include "SizeofExpressionCheck.h"
66 #include "SpuriouslyWakeUpFunctionsCheck.h"
67 #include "StandaloneEmptyCheck.h"
68 #include "StringConstructorCheck.h"
69 #include "StringIntegerAssignmentCheck.h"
70 #include "StringLiteralWithEmbeddedNulCheck.h"
71 #include "StringviewNullptrCheck.h"
72 #include "SuspiciousEnumUsageCheck.h"
73 #include "SuspiciousIncludeCheck.h"
74 #include "SuspiciousMemoryComparisonCheck.h"
75 #include "SuspiciousMemsetUsageCheck.h"
76 #include "SuspiciousMissingCommaCheck.h"
77 #include "SuspiciousReallocUsageCheck.h"
78 #include "SuspiciousSemicolonCheck.h"
79 #include "SuspiciousStringCompareCheck.h"
80 #include "SuspiciousStringviewDataUsageCheck.h"
81 #include "SwappedArgumentsCheck.h"
82 #include "SwitchMissingDefaultCaseCheck.h"
83 #include "TaggedUnionMemberCountCheck.h"
84 #include "TerminatingContinueCheck.h"
85 #include "ThrowKeywordMissingCheck.h"
86 #include "TooSmallLoopVariableCheck.h"
87 #include "UncheckedOptionalAccessCheck.h"
88 #include "UndefinedMemoryManipulationCheck.h"
89 #include "UndelegatedConstructorCheck.h"
90 #include "UnhandledExceptionAtNewCheck.h"
91 #include "UnhandledSelfAssignmentCheck.h"
92 #include "UniquePtrArrayMismatchCheck.h"
93 #include "UnsafeFunctionsCheck.h"
94 #include "UnusedLocalNonTrivialVariableCheck.h"
95 #include "UnusedRaiiCheck.h"
96 #include "UnusedReturnValueCheck.h"
97 #include "UseAfterMoveCheck.h"
98 #include "VirtualNearMissCheck.h"
100 namespace clang::tidy {
101 namespace bugprone {
103 class BugproneModule : public ClangTidyModule {
104 public:
105 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
106 CheckFactories.registerCheck<ArgumentCommentCheck>(
107 "bugprone-argument-comment");
108 CheckFactories.registerCheck<AssertSideEffectCheck>(
109 "bugprone-assert-side-effect");
110 CheckFactories.registerCheck<AssignmentInIfConditionCheck>(
111 "bugprone-assignment-in-if-condition");
112 CheckFactories.registerCheck<BadSignalToKillThreadCheck>(
113 "bugprone-bad-signal-to-kill-thread");
114 CheckFactories.registerCheck<BitwisePointerCastCheck>(
115 "bugprone-bitwise-pointer-cast");
116 CheckFactories.registerCheck<BoolPointerImplicitConversionCheck>(
117 "bugprone-bool-pointer-implicit-conversion");
118 CheckFactories.registerCheck<BranchCloneCheck>("bugprone-branch-clone");
119 CheckFactories.registerCheck<CastingThroughVoidCheck>(
120 "bugprone-casting-through-void");
121 CheckFactories.registerCheck<ChainedComparisonCheck>(
122 "bugprone-chained-comparison");
123 CheckFactories.registerCheck<ComparePointerToMemberVirtualFunctionCheck>(
124 "bugprone-compare-pointer-to-member-virtual-function");
125 CheckFactories.registerCheck<CopyConstructorInitCheck>(
126 "bugprone-copy-constructor-init");
127 CheckFactories.registerCheck<DanglingHandleCheck>(
128 "bugprone-dangling-handle");
129 CheckFactories.registerCheck<DynamicStaticInitializersCheck>(
130 "bugprone-dynamic-static-initializers");
131 CheckFactories.registerCheck<EasilySwappableParametersCheck>(
132 "bugprone-easily-swappable-parameters");
133 CheckFactories.registerCheck<EmptyCatchCheck>("bugprone-empty-catch");
134 CheckFactories.registerCheck<ExceptionEscapeCheck>(
135 "bugprone-exception-escape");
136 CheckFactories.registerCheck<FoldInitTypeCheck>("bugprone-fold-init-type");
137 CheckFactories.registerCheck<ForwardDeclarationNamespaceCheck>(
138 "bugprone-forward-declaration-namespace");
139 CheckFactories.registerCheck<ForwardingReferenceOverloadCheck>(
140 "bugprone-forwarding-reference-overload");
141 CheckFactories.registerCheck<ImplicitWideningOfMultiplicationResultCheck>(
142 "bugprone-implicit-widening-of-multiplication-result");
143 CheckFactories.registerCheck<InaccurateEraseCheck>(
144 "bugprone-inaccurate-erase");
145 CheckFactories.registerCheck<IncorrectEnableIfCheck>(
146 "bugprone-incorrect-enable-if");
147 CheckFactories.registerCheck<ReturnConstRefFromParameterCheck>(
148 "bugprone-return-const-ref-from-parameter");
149 CheckFactories.registerCheck<SwitchMissingDefaultCaseCheck>(
150 "bugprone-switch-missing-default-case");
151 CheckFactories.registerCheck<IncDecInConditionsCheck>(
152 "bugprone-inc-dec-in-conditions");
153 CheckFactories.registerCheck<IncorrectRoundingsCheck>(
154 "bugprone-incorrect-roundings");
155 CheckFactories.registerCheck<InfiniteLoopCheck>("bugprone-infinite-loop");
156 CheckFactories.registerCheck<IntegerDivisionCheck>(
157 "bugprone-integer-division");
158 CheckFactories.registerCheck<LambdaFunctionNameCheck>(
159 "bugprone-lambda-function-name");
160 CheckFactories.registerCheck<MacroParenthesesCheck>(
161 "bugprone-macro-parentheses");
162 CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>(
163 "bugprone-macro-repeated-side-effects");
164 CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>(
165 "bugprone-misplaced-operator-in-strlen-in-alloc");
166 CheckFactories.registerCheck<MisplacedPointerArithmeticInAllocCheck>(
167 "bugprone-misplaced-pointer-arithmetic-in-alloc");
168 CheckFactories.registerCheck<MisplacedWideningCastCheck>(
169 "bugprone-misplaced-widening-cast");
170 CheckFactories.registerCheck<MoveForwardingReferenceCheck>(
171 "bugprone-move-forwarding-reference");
172 CheckFactories.registerCheck<MultiLevelImplicitPointerConversionCheck>(
173 "bugprone-multi-level-implicit-pointer-conversion");
174 CheckFactories.registerCheck<MultipleNewInOneExpressionCheck>(
175 "bugprone-multiple-new-in-one-expression");
176 CheckFactories.registerCheck<MultipleStatementMacroCheck>(
177 "bugprone-multiple-statement-macro");
178 CheckFactories.registerCheck<NondeterministicPointerIterationOrderCheck>(
179 "bugprone-nondeterministic-pointer-iteration-order");
180 CheckFactories.registerCheck<OptionalValueConversionCheck>(
181 "bugprone-optional-value-conversion");
182 CheckFactories.registerCheck<PointerArithmeticOnPolymorphicObjectCheck>(
183 "bugprone-pointer-arithmetic-on-polymorphic-object");
184 CheckFactories.registerCheck<RedundantBranchConditionCheck>(
185 "bugprone-redundant-branch-condition");
186 CheckFactories.registerCheck<cppcoreguidelines::NarrowingConversionsCheck>(
187 "bugprone-narrowing-conversions");
188 CheckFactories.registerCheck<NoEscapeCheck>("bugprone-no-escape");
189 CheckFactories.registerCheck<NonZeroEnumToBoolConversionCheck>(
190 "bugprone-non-zero-enum-to-bool-conversion");
191 CheckFactories.registerCheck<NotNullTerminatedResultCheck>(
192 "bugprone-not-null-terminated-result");
193 CheckFactories.registerCheck<ParentVirtualCallCheck>(
194 "bugprone-parent-virtual-call");
195 CheckFactories.registerCheck<PosixReturnCheck>("bugprone-posix-return");
196 CheckFactories.registerCheck<ReservedIdentifierCheck>(
197 "bugprone-reserved-identifier");
198 CheckFactories.registerCheck<SharedPtrArrayMismatchCheck>(
199 "bugprone-shared-ptr-array-mismatch");
200 CheckFactories.registerCheck<SignalHandlerCheck>("bugprone-signal-handler");
201 CheckFactories.registerCheck<SignedCharMisuseCheck>(
202 "bugprone-signed-char-misuse");
203 CheckFactories.registerCheck<SizeofContainerCheck>(
204 "bugprone-sizeof-container");
205 CheckFactories.registerCheck<SizeofExpressionCheck>(
206 "bugprone-sizeof-expression");
207 CheckFactories.registerCheck<SpuriouslyWakeUpFunctionsCheck>(
208 "bugprone-spuriously-wake-up-functions");
209 CheckFactories.registerCheck<StandaloneEmptyCheck>(
210 "bugprone-standalone-empty");
211 CheckFactories.registerCheck<StringConstructorCheck>(
212 "bugprone-string-constructor");
213 CheckFactories.registerCheck<StringIntegerAssignmentCheck>(
214 "bugprone-string-integer-assignment");
215 CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>(
216 "bugprone-string-literal-with-embedded-nul");
217 CheckFactories.registerCheck<StringviewNullptrCheck>(
218 "bugprone-stringview-nullptr");
219 CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
220 "bugprone-suspicious-enum-usage");
221 CheckFactories.registerCheck<SuspiciousIncludeCheck>(
222 "bugprone-suspicious-include");
223 CheckFactories.registerCheck<SuspiciousMemoryComparisonCheck>(
224 "bugprone-suspicious-memory-comparison");
225 CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>(
226 "bugprone-suspicious-memset-usage");
227 CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(
228 "bugprone-suspicious-missing-comma");
229 CheckFactories.registerCheck<SuspiciousReallocUsageCheck>(
230 "bugprone-suspicious-realloc-usage");
231 CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
232 "bugprone-suspicious-semicolon");
233 CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
234 "bugprone-suspicious-string-compare");
235 CheckFactories.registerCheck<SuspiciousStringviewDataUsageCheck>(
236 "bugprone-suspicious-stringview-data-usage");
237 CheckFactories.registerCheck<SwappedArgumentsCheck>(
238 "bugprone-swapped-arguments");
239 CheckFactories.registerCheck<TaggedUnionMemberCountCheck>(
240 "bugprone-tagged-union-member-count");
241 CheckFactories.registerCheck<TerminatingContinueCheck>(
242 "bugprone-terminating-continue");
243 CheckFactories.registerCheck<ThrowKeywordMissingCheck>(
244 "bugprone-throw-keyword-missing");
245 CheckFactories.registerCheck<TooSmallLoopVariableCheck>(
246 "bugprone-too-small-loop-variable");
247 CheckFactories.registerCheck<UncheckedOptionalAccessCheck>(
248 "bugprone-unchecked-optional-access");
249 CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>(
250 "bugprone-undefined-memory-manipulation");
251 CheckFactories.registerCheck<UndelegatedConstructorCheck>(
252 "bugprone-undelegated-constructor");
253 CheckFactories.registerCheck<UnhandledSelfAssignmentCheck>(
254 "bugprone-unhandled-self-assignment");
255 CheckFactories.registerCheck<UnhandledExceptionAtNewCheck>(
256 "bugprone-unhandled-exception-at-new");
257 CheckFactories.registerCheck<UniquePtrArrayMismatchCheck>(
258 "bugprone-unique-ptr-array-mismatch");
259 CheckFactories.registerCheck<CrtpConstructorAccessibilityCheck>(
260 "bugprone-crtp-constructor-accessibility");
261 CheckFactories.registerCheck<UnsafeFunctionsCheck>(
262 "bugprone-unsafe-functions");
263 CheckFactories.registerCheck<UnusedLocalNonTrivialVariableCheck>(
264 "bugprone-unused-local-non-trivial-variable");
265 CheckFactories.registerCheck<UnusedRaiiCheck>("bugprone-unused-raii");
266 CheckFactories.registerCheck<UnusedReturnValueCheck>(
267 "bugprone-unused-return-value");
268 CheckFactories.registerCheck<UseAfterMoveCheck>("bugprone-use-after-move");
269 CheckFactories.registerCheck<VirtualNearMissCheck>(
270 "bugprone-virtual-near-miss");
274 } // namespace bugprone
276 // Register the BugproneTidyModule using this statically initialized variable.
277 static ClangTidyModuleRegistry::Add<bugprone::BugproneModule>
278 X("bugprone-module", "Adds checks for bugprone code constructs.");
280 // This anchor is used to force the linker to link in the generated object file
281 // and thus register the BugproneModule.
282 volatile int BugproneModuleAnchorSource = 0;
284 } // namespace clang::tidy