clang-tools 19.0.0git
ReadabilityTidyModule.cpp
Go to the documentation of this file.
1//===--- ReadabilityTidyModule.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//===----------------------------------------------------------------------===//
8
9#include "../ClangTidy.h"
10#include "../ClangTidyModule.h"
11#include "../ClangTidyModuleRegistry.h"
26#include "FunctionSizeCheck.h"
32#include "MagicNumbersCheck.h"
36#include "NamedParameterCheck.h"
39#include "QualifiedAutoCheck.h"
56#include "StringCompareCheck.h"
60#include "UseAnyOfAllOfCheck.h"
61#include "UseStdMinMaxCheck.h"
62
63namespace clang::tidy {
64namespace readability {
65
67public:
68 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
70 "readability-avoid-const-params-in-decls");
72 "readability-avoid-nested-conditional-operator");
74 "readability-avoid-return-with-void-value");
76 "readability-avoid-unconditional-preprocessor-if");
78 "readability-braces-around-statements");
79 CheckFactories.registerCheck<ConstReturnTypeCheck>(
80 "readability-const-return-type");
82 "readability-container-contains");
84 "readability-container-data-pointer");
86 "readability-container-size-empty");
88 "readability-convert-member-functions-to-static");
90 "readability-delete-null-pointer");
92 "readability-duplicate-include");
93 CheckFactories.registerCheck<ElseAfterReturnCheck>(
94 "readability-else-after-return");
96 "readability-function-cognitive-complexity");
97 CheckFactories.registerCheck<FunctionSizeCheck>(
98 "readability-function-size");
100 "readability-identifier-length");
101 CheckFactories.registerCheck<IdentifierNamingCheck>(
102 "readability-identifier-naming");
104 "readability-implicit-bool-conversion");
106 "readability-redundant-inline-specifier");
108 "readability-inconsistent-declaration-parameter-name");
110 "readability-isolate-declaration");
111 CheckFactories.registerCheck<MagicNumbersCheck>(
112 "readability-magic-numbers");
114 "readability-make-member-function-const");
116 "readability-misleading-indentation");
118 "readability-misplaced-array-index");
120 "readability-operators-representation");
121 CheckFactories.registerCheck<QualifiedAutoCheck>(
122 "readability-qualified-auto");
124 "readability-redundant-access-specifiers");
125 CheckFactories.registerCheck<RedundantCastingCheck>(
126 "readability-redundant-casting");
128 "readability-redundant-function-ptr-dereference");
130 "readability-redundant-member-init");
132 "readability-redundant-preprocessor");
134 "readability-reference-to-constructed-temporary");
136 "readability-simplify-subscript-expr");
138 "readability-static-accessed-through-instance");
140 "readability-static-definition-in-anonymous-namespace");
141 CheckFactories.registerCheck<StringCompareCheck>(
142 "readability-string-compare");
144 "readability-named-parameter");
146 "readability-non-const-parameter");
148 "readability-redundant-control-flow");
150 "readability-redundant-declaration");
152 "readability-redundant-smartptr-get");
154 "readability-redundant-string-cstr");
156 "readability-redundant-string-init");
158 "readability-simplify-boolean-expr");
160 "readability-suspicious-call-argument");
162 "readability-uniqueptr-delete-release");
164 "readability-uppercase-literal-suffix");
165 CheckFactories.registerCheck<UseAnyOfAllOfCheck>(
166 "readability-use-anyofallof");
167 CheckFactories.registerCheck<UseStdMinMaxCheck>(
168 "readability-use-std-min-max");
169 }
170};
171
172// Register the ReadabilityModule using this statically initialized variable.
173static ClangTidyModuleRegistry::Add<ReadabilityModule>
174 X("readability-module", "Adds readability-related checks.");
175
176} // namespace readability
177
178// This anchor is used to force the linker to link in the generated object file
179// and thus register the ReadabilityModule.
181
182} // namespace clang::tidy
int X
A collection of ClangTidyCheckFactory instances.
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Identifies instances of nested conditional operators in the code.
Finds return statements with void values used within functions with void result types.
Finds code blocks that are constantly enabled or disabled in preprocessor directives by analyzing #if...
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
For any function whose return type is const-qualified, suggests removal of the const qualifier from t...
Finds usages of container.count() and find() == end() which should be replaced by a call to the conta...
Checks whether a call to operator[] and & can be replaced with a call to data().
Checks whether a call to the size()/length() method can be replaced with a call to empty().
This check finds C++ class methods than can be made static because they don't use the 'this' pointer.
Check whether the 'if' statement is unnecessary before calling 'delete' on a pointer.
Find and remove duplicate #include directives.
Flags the usages of else after return.
Checks for large functions based on various metrics.
Warns about identifiers names whose length is too short.
Checks for identifiers naming style mismatch.
Checks for use of implicit bool conversions in expressions.
Checks for declarations of functions which differ in parameter names.
This check diagnoses all DeclStmt's declaring more than one variable and tries to refactor the code t...
Detects magic numbers, integer and floating point literals embedded in code.
Finds non-static member functions that can be made 'const'.
Checks the code for dangling else, and possible misleading indentations due to missing braces.
Warn about unusual array index syntax (index[array] instead of array[index]).
Find functions with unnamed arguments.
Warn when a pointer function parameter can be const.
Enforces consistent token representation for invoked binary, unary and overloaded operators in C++ co...
Finds variables declared as auto that could be declared as: 'auto*' or 'const auto *' and reference v...
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Detects redundant access specifiers inside classes, structs, and unions.
Detects explicit type casting operations that involve the same source and destination types,...
Eliminates redundant return statements at the end of a function that returns void.
Detects redundant inline specifiers on function and variable declarations.
Finds member initializations that are unnecessary because the same default constructor would be calle...
This check flags redundant preprocessor directives: nested directives with the same condition.
Find and remove redundant calls to smart pointer's .get() method.
Finds unnecessary calls to std::string::c_str().
Finds unnecessary string initializations.
Detects C++ code where a reference variable is used to extend the lifetime of a temporary object that...
Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate ...
Checks for member expressions that access static members through instances and replaces them with use...
Finds static function and variable definitions in anonymous namespace.
This check flags all calls compare when used to check for string equality or inequality.
Finds function calls where the arguments passed are provided out of order, based on the difference be...
Flags statements of the form delete <unique_ptr expr>.release(); and replaces them with: <unique_ptr ...
Detects when the integral literal or floating point literal has non-uppercase suffix,...
Finds ranged-based for loops that can be replaced by a call to std::any_of or std::all_of.
Replaces certain conditional statements with equivalent calls to std::min or std::max.
volatile int ReadabilityModuleAnchorSource