clang-tools 23.0.0git
ReadabilityTidyModule.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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//===----------------------------------------------------------------------===//
8
9#include "../ClangTidy.h"
10#include "../ClangTidyModule.h"
27#include "FunctionSizeCheck.h"
34#include "MagicNumbersCheck.h"
39#include "NamedParameterCheck.h"
42#include "QualifiedAutoCheck.h"
64#include "StringCompareCheck.h"
66#include "TrailingCommaCheck.h"
67#include "TrivialSwitchCheck.h"
70#include "UseAnyOfAllOfCheck.h"
72#include "UseStdMinMaxCheck.h"
73
74namespace clang::tidy {
75namespace readability {
76namespace {
77
78class ReadabilityModule : public ClangTidyModule {
79public:
80 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
81 CheckFactories.registerCheck<AmbiguousSmartptrResetCallCheck>(
82 "readability-ambiguous-smartptr-reset-call");
83 CheckFactories.registerCheck<AvoidConstParamsInDeclsCheck>(
84 "readability-avoid-const-params-in-decls");
85 CheckFactories.registerCheck<AvoidNestedConditionalOperatorCheck>(
86 "readability-avoid-nested-conditional-operator");
87 CheckFactories.registerCheck<AvoidReturnWithVoidValueCheck>(
88 "readability-avoid-return-with-void-value");
89 CheckFactories.registerCheck<AvoidUnconditionalPreprocessorIfCheck>(
90 "readability-avoid-unconditional-preprocessor-if");
91 CheckFactories.registerCheck<BracesAroundStatementsCheck>(
92 "readability-braces-around-statements");
93 CheckFactories.registerCheck<ConstReturnTypeCheck>(
94 "readability-const-return-type");
95 CheckFactories.registerCheck<ContainerContainsCheck>(
96 "readability-container-contains");
97 CheckFactories.registerCheck<ContainerDataPointerCheck>(
98 "readability-container-data-pointer");
99 CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
100 "readability-container-size-empty");
101 CheckFactories.registerCheck<ConvertMemberFunctionsToStaticCheck>(
102 "readability-convert-member-functions-to-static");
103 CheckFactories.registerCheck<DeleteNullPointerCheck>(
104 "readability-delete-null-pointer");
105 CheckFactories.registerCheck<DuplicateIncludeCheck>(
106 "readability-duplicate-include");
107 CheckFactories.registerCheck<ElseAfterReturnCheck>(
108 "readability-else-after-return");
109 CheckFactories.registerCheck<EnumInitialValueCheck>(
110 "readability-enum-initial-value");
111 CheckFactories.registerCheck<FunctionCognitiveComplexityCheck>(
112 "readability-function-cognitive-complexity");
113 CheckFactories.registerCheck<FunctionSizeCheck>(
114 "readability-function-size");
115 CheckFactories.registerCheck<IdentifierLengthCheck>(
116 "readability-identifier-length");
117 CheckFactories.registerCheck<IdentifierNamingCheck>(
118 "readability-identifier-naming");
119 CheckFactories.registerCheck<ImplicitBoolConversionCheck>(
120 "readability-implicit-bool-conversion");
121 CheckFactories.registerCheck<InconsistentIfElseBracesCheck>(
122 "readability-inconsistent-ifelse-braces");
123 CheckFactories.registerCheck<MathMissingParenthesesCheck>(
124 "readability-math-missing-parentheses");
125 CheckFactories.registerCheck<RedundantInlineSpecifierCheck>(
126 "readability-redundant-inline-specifier");
127 CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>(
128 "readability-inconsistent-declaration-parameter-name");
129 CheckFactories.registerCheck<IsolateDeclarationCheck>(
130 "readability-isolate-declaration");
131 CheckFactories.registerCheck<MagicNumbersCheck>(
132 "readability-magic-numbers");
133 CheckFactories.registerCheck<MakeMemberFunctionConstCheck>(
134 "readability-make-member-function-const");
135 CheckFactories.registerCheck<MisleadingIndentationCheck>(
136 "readability-misleading-indentation");
137 CheckFactories.registerCheck<MisplacedArrayIndexCheck>(
138 "readability-misplaced-array-index");
139 CheckFactories.registerCheck<OperatorsRepresentationCheck>(
140 "readability-operators-representation");
141 CheckFactories.registerCheck<QualifiedAutoCheck>(
142 "readability-qualified-auto");
143 CheckFactories.registerCheck<RedundantAccessSpecifiersCheck>(
144 "readability-redundant-access-specifiers");
145 CheckFactories.registerCheck<RedundantCastingCheck>(
146 "readability-redundant-casting");
147 CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>(
148 "readability-redundant-function-ptr-dereference");
149 CheckFactories.registerCheck<RedundantLambdaParameterListCheck>(
150 "readability-redundant-lambda-parameter-list");
151 CheckFactories.registerCheck<RedundantMemberInitCheck>(
152 "readability-redundant-member-init");
153 CheckFactories.registerCheck<RedundantNestedIfCheck>(
154 "readability-redundant-nested-if");
155 CheckFactories.registerCheck<RedundantParenthesesCheck>(
156 "readability-redundant-parentheses");
157 CheckFactories.registerCheck<RedundantPreprocessorCheck>(
158 "readability-redundant-preprocessor");
159 CheckFactories.registerCheck<RedundantQualifiedAliasCheck>(
160 "readability-redundant-qualified-alias");
161 CheckFactories.registerCheck<RedundantTypenameCheck>(
162 "readability-redundant-typename");
163 CheckFactories.registerCheck<ReferenceToConstructedTemporaryCheck>(
164 "readability-reference-to-constructed-temporary");
165 CheckFactories.registerCheck<SimplifySubscriptExprCheck>(
166 "readability-simplify-subscript-expr");
167 CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>(
168 "readability-static-accessed-through-instance");
169 CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>(
170 "readability-static-definition-in-anonymous-namespace");
171 CheckFactories.registerCheck<StringCompareCheck>(
172 "readability-string-compare");
173 CheckFactories.registerCheck<readability::NamedParameterCheck>(
174 "readability-named-parameter");
175 CheckFactories.registerCheck<NonConstParameterCheck>(
176 "readability-non-const-parameter");
177 CheckFactories.registerCheck<RedundantControlFlowCheck>(
178 "readability-redundant-control-flow");
179 CheckFactories.registerCheck<RedundantDeclarationCheck>(
180 "readability-redundant-declaration");
181 CheckFactories.registerCheck<RedundantSmartptrGetCheck>(
182 "readability-redundant-smartptr-get");
183 CheckFactories.registerCheck<RedundantStringCStrCheck>(
184 "readability-redundant-string-cstr");
185 CheckFactories.registerCheck<RedundantStringInitCheck>(
186 "readability-redundant-string-init");
187 CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
188 "readability-simplify-boolean-expr");
189 CheckFactories.registerCheck<SuspiciousCallArgumentCheck>(
190 "readability-suspicious-call-argument");
191 CheckFactories.registerCheck<TrailingCommaCheck>(
192 "readability-trailing-comma");
193 CheckFactories.registerCheck<TrivialSwitchCheck>(
194 "readability-trivial-switch");
195 CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(
196 "readability-uniqueptr-delete-release");
197 CheckFactories.registerCheck<UppercaseLiteralSuffixCheck>(
198 "readability-uppercase-literal-suffix");
199 CheckFactories.registerCheck<UseAnyOfAllOfCheck>(
200 "readability-use-anyofallof");
201 CheckFactories.registerCheck<UseConcisePreprocessorDirectivesCheck>(
202 "readability-use-concise-preprocessor-directives");
203 CheckFactories.registerCheck<UseStdMinMaxCheck>(
204 "readability-use-std-min-max");
205 }
206};
207
208} // namespace
209
210// Register the ReadabilityModule using this statically initialized variable.
211static ClangTidyModuleRegistry::Add<ReadabilityModule>
212 X("readability-module", "Adds readability-related checks.");
213
214} // namespace readability
215
216// This anchor is used to force the linker to link in the generated object file
217// and thus register the ReadabilityModule.
218// NOLINTNEXTLINE(misc-use-internal-linkage)
220
221} // namespace clang::tidy
static ClangTidyModuleRegistry::Add< ReadabilityModule > X("readability-module", "Adds readability-related checks.")
volatile int ReadabilityModuleAnchorSource