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