clang-tools 17.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"
23#include "FunctionSizeCheck.h"
29#include "MagicNumbersCheck.h"
33#include "NamedParameterCheck.h"
35#include "QualifiedAutoCheck.h"
49#include "StringCompareCheck.h"
53#include "UseAnyOfAllOfCheck.h"
54
55namespace clang::tidy {
56namespace readability {
57
59public:
60 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
62 "readability-avoid-const-params-in-decls");
64 "readability-braces-around-statements");
65 CheckFactories.registerCheck<ConstReturnTypeCheck>(
66 "readability-const-return-type");
68 "readability-container-contains");
70 "readability-container-data-pointer");
72 "readability-container-size-empty");
74 "readability-convert-member-functions-to-static");
76 "readability-delete-null-pointer");
78 "readability-duplicate-include");
79 CheckFactories.registerCheck<ElseAfterReturnCheck>(
80 "readability-else-after-return");
82 "readability-function-cognitive-complexity");
83 CheckFactories.registerCheck<FunctionSizeCheck>(
84 "readability-function-size");
86 "readability-identifier-length");
88 "readability-identifier-naming");
90 "readability-implicit-bool-conversion");
92 "readability-inconsistent-declaration-parameter-name");
94 "readability-isolate-declaration");
95 CheckFactories.registerCheck<MagicNumbersCheck>(
96 "readability-magic-numbers");
98 "readability-make-member-function-const");
100 "readability-misleading-indentation");
102 "readability-misplaced-array-index");
103 CheckFactories.registerCheck<QualifiedAutoCheck>(
104 "readability-qualified-auto");
106 "readability-redundant-access-specifiers");
108 "readability-redundant-function-ptr-dereference");
110 "readability-redundant-member-init");
112 "readability-redundant-preprocessor");
114 "readability-simplify-subscript-expr");
116 "readability-static-accessed-through-instance");
118 "readability-static-definition-in-anonymous-namespace");
119 CheckFactories.registerCheck<StringCompareCheck>(
120 "readability-string-compare");
122 "readability-named-parameter");
124 "readability-non-const-parameter");
126 "readability-redundant-control-flow");
128 "readability-redundant-declaration");
130 "readability-redundant-smartptr-get");
132 "readability-redundant-string-cstr");
134 "readability-redundant-string-init");
136 "readability-simplify-boolean-expr");
138 "readability-suspicious-call-argument");
140 "readability-uniqueptr-delete-release");
142 "readability-uppercase-literal-suffix");
143 CheckFactories.registerCheck<UseAnyOfAllOfCheck>(
144 "readability-use-anyofallof");
145 }
146};
147
148// Register the ReadabilityModule using this statically initialized variable.
149static ClangTidyModuleRegistry::Add<ReadabilityModule>
150 X("readability-module", "Adds readability-related checks.");
151
152} // namespace readability
153
154// This anchor is used to force the linker to link in the generated object file
155// and thus register the ReadabilityModule.
157
158} // 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.
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() 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.
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.
Eliminates redundant return statements at the end of a function that returns void.
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.
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.
volatile int ReadabilityModuleAnchorSource