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