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