clang-tools  14.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"
14 #include "ConstReturnTypeCheck.h"
18 #include "DeleteNullPointerCheck.h"
19 #include "ElseAfterReturnCheck.h"
21 #include "FunctionSizeCheck.h"
22 #include "IdentifierLengthCheck.h"
23 #include "IdentifierNamingCheck.h"
27 #include "MagicNumbersCheck.h"
31 #include "NamedParameterCheck.h"
32 #include "NonConstParameterCheck.h"
33 #include "QualifiedAutoCheck.h"
47 #include "StringCompareCheck.h"
51 #include "UseAnyOfAllOfCheck.h"
52 
53 namespace clang {
54 namespace tidy {
55 namespace readability {
56 
58 public:
59  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
60  CheckFactories.registerCheck<AvoidConstParamsInDecls>(
61  "readability-avoid-const-params-in-decls");
63  "readability-braces-around-statements");
64  CheckFactories.registerCheck<ConstReturnTypeCheck>(
65  "readability-const-return-type");
67  "readability-container-data-pointer");
68  CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
69  "readability-container-size-empty");
71  "readability-convert-member-functions-to-static");
72  CheckFactories.registerCheck<DeleteNullPointerCheck>(
73  "readability-delete-null-pointer");
74  CheckFactories.registerCheck<ElseAfterReturnCheck>(
75  "readability-else-after-return");
77  "readability-function-cognitive-complexity");
78  CheckFactories.registerCheck<FunctionSizeCheck>(
79  "readability-function-size");
80  CheckFactories.registerCheck<IdentifierLengthCheck>(
81  "readability-identifier-length");
82  CheckFactories.registerCheck<IdentifierNamingCheck>(
83  "readability-identifier-naming");
85  "readability-implicit-bool-conversion");
87  "readability-inconsistent-declaration-parameter-name");
88  CheckFactories.registerCheck<IsolateDeclarationCheck>(
89  "readability-isolate-declaration");
90  CheckFactories.registerCheck<MagicNumbersCheck>(
91  "readability-magic-numbers");
93  "readability-make-member-function-const");
95  "readability-misleading-indentation");
97  "readability-misplaced-array-index");
98  CheckFactories.registerCheck<QualifiedAutoCheck>(
99  "readability-qualified-auto");
101  "readability-redundant-access-specifiers");
103  "readability-redundant-function-ptr-dereference");
104  CheckFactories.registerCheck<RedundantMemberInitCheck>(
105  "readability-redundant-member-init");
107  "readability-redundant-preprocessor");
109  "readability-simplify-subscript-expr");
111  "readability-static-accessed-through-instance");
113  "readability-static-definition-in-anonymous-namespace");
114  CheckFactories.registerCheck<StringCompareCheck>(
115  "readability-string-compare");
117  "readability-named-parameter");
118  CheckFactories.registerCheck<NonConstParameterCheck>(
119  "readability-non-const-parameter");
121  "readability-redundant-control-flow");
123  "readability-redundant-declaration");
125  "readability-redundant-smartptr-get");
126  CheckFactories.registerCheck<RedundantStringCStrCheck>(
127  "readability-redundant-string-cstr");
128  CheckFactories.registerCheck<RedundantStringInitCheck>(
129  "readability-redundant-string-init");
130  CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
131  "readability-simplify-boolean-expr");
133  "readability-suspicious-call-argument");
135  "readability-uniqueptr-delete-release");
137  "readability-uppercase-literal-suffix");
138  CheckFactories.registerCheck<UseAnyOfAllOfCheck>(
139  "readability-use-anyofallof");
140  }
141 };
142 
143 // Register the ReadabilityModule using this statically initialized variable.
144 static ClangTidyModuleRegistry::Add<ReadabilityModule>
145  X("readability-module", "Adds readability-related checks.");
146 
147 } // namespace readability
148 
149 // This anchor is used to force the linker to link in the generated object file
150 // and thus register the ReadabilityModule.
152 
153 } // namespace tidy
154 } // namespace clang
ImplicitBoolConversionCheck.h
clang::tidy::readability::SuspiciousCallArgumentCheck
Finds function calls where the arguments passed are provided out of order, based on the difference be...
Definition: SuspiciousCallArgumentCheck.h:25
clang::tidy::readability::RedundantStringCStrCheck
Finds unnecessary calls to std::string::c_str().
Definition: RedundantStringCStrCheck.h:19
clang::tidy::readability::MisleadingIndentationCheck
Checks the code for dangling else, and possible misleading indentations due to missing braces.
Definition: MisleadingIndentationCheck.h:24
clang::tidy::ReadabilityModuleAnchorSource
volatile int ReadabilityModuleAnchorSource
Definition: ReadabilityTidyModule.cpp:151
AvoidConstParamsInDecls.h
IsolateDeclarationCheck.h
InconsistentDeclarationParameterNameCheck.h
clang::tidy::readability::RedundantDeclarationCheck
Find redundant variable declarations.
Definition: RedundantDeclarationCheck.h:22
clang::tidy::readability::BracesAroundStatementsCheck
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
Definition: BracesAroundStatementsCheck.h:43
RedundantStringInitCheck.h
FunctionCognitiveComplexityCheck.h
clang::tidy::readability::RedundantSmartptrGetCheck
Find and remove redundant calls to smart pointer's .get() method.
Definition: RedundantSmartptrGetCheck.h:27
clang::tidy::readability::RedundantFunctionPtrDereferenceCheck
Eliminate redundant dereferences of a function pointer.
Definition: RedundantFunctionPtrDereferenceCheck.h:22
QualifiedAutoCheck.h
IdentifierNamingCheck.h
clang::tidy::readability::MakeMemberFunctionConstCheck
Finds non-static member functions that can be made 'const'.
Definition: MakeMemberFunctionConstCheck.h:22
clang::tidy::readability::RedundantMemberInitCheck
Finds member initializations that are unnecessary because the same default constructor would be calle...
Definition: RedundantMemberInitCheck.h:23
RedundantFunctionPtrDereferenceCheck.h
clang::tidy::readability::RedundantControlFlowCheck
Eliminates redundant return statements at the end of a function that returns void.
Definition: RedundantControlFlowCheck.h:25
clang::tidy::readability::RedundantStringInitCheck
Finds unnecessary string initializations.
Definition: RedundantStringInitCheck.h:21
RedundantAccessSpecifiersCheck.h
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:28
clang::tidy::readability::ReadabilityModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Definition: ReadabilityTidyModule.cpp:59
clang::tidy::readability::UppercaseLiteralSuffixCheck
Detects when the integral literal or floating point literal has non-uppercase suffix,...
Definition: UppercaseLiteralSuffixCheck.h:25
BracesAroundStatementsCheck.h
clang::tidy::readability::InconsistentDeclarationParameterNameCheck
Checks for declarations of functions which differ in parameter names.
Definition: InconsistentDeclarationParameterNameCheck.h:25
ConvertMemberFunctionsToStatic.h
DeleteNullPointerCheck.h
StringCompareCheck.h
IdentifierLengthCheck.h
clang::tidy::readability::ContainerSizeEmptyCheck
Checks whether a call to the size() method can be replaced with a call to empty().
Definition: ContainerSizeEmptyCheck.h:28
UniqueptrDeleteReleaseCheck.h
ConstReturnTypeCheck.h
clang::tidy::readability::NonConstParameterCheck
Warn when a pointer function parameter can be const.
Definition: NonConstParameterCheck.h:22
clang::tidy::readability::IdentifierLengthCheck
Warns about identifiers names whose length is too short.
Definition: IdentifierLengthCheck.h:24
NamedParameterCheck.h
RedundantSmartptrGetCheck.h
SuspiciousCallArgumentCheck.h
RedundantStringCStrCheck.h
clang::tidy::readability::SimplifyBooleanExprCheck
Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate ...
Definition: SimplifyBooleanExprCheck.h:23
UseAnyOfAllOfCheck.h
ContainerDataPointerCheck.h
StaticAccessedThroughInstanceCheck.h
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition: FunctionSizeCheck.h:37
clang::tidy::readability::StringCompareCheck
This check flags all calls compare when used to check for string equality or inequality.
Definition: StringCompareCheck.h:23
MisplacedArrayIndexCheck.h
clang::tidy::readability::MagicNumbersCheck
Detects magic numbers, integer and floating point literals embedded in code.
Definition: MagicNumbersCheck.h:25
ContainerSizeEmptyCheck.h
SimplifyBooleanExprCheck.h
clang::tidy::readability::ConvertMemberFunctionsToStatic
This check finds C++ class methods than can be made static because they don't use the 'this' pointer.
Definition: ConvertMemberFunctionsToStatic.h:24
clang::tidy::readability::StaticAccessedThroughInstanceCheck
Checks for member expressions that access static members through instances and replaces them with use...
Definition: StaticAccessedThroughInstanceCheck.h:23
clang::tidy::readability::ReadabilityModule
Definition: ReadabilityTidyModule.cpp:57
clang::tidy::readability::UseAnyOfAllOfCheck
Finds ranged-based for loops that can be replaced by a call to std::any_of or std::all_of.
Definition: UseAnyOfAllOfCheck.h:24
RedundantPreprocessorCheck.h
clang::tidy::readability::ElseAfterReturnCheck
Flags the usages of else after return.
Definition: ElseAfterReturnCheck.h:22
clang::tidy::readability::MisplacedArrayIndexCheck
Warn about unusual array index syntax (index[array] instead of array[index]).
Definition: MisplacedArrayIndexCheck.h:23
SimplifySubscriptExprCheck.h
RedundantDeclarationCheck.h
clang::tidy::readability::SimplifySubscriptExprCheck
Simplifies subscript expressions.
Definition: SimplifySubscriptExprCheck.h:22
StaticDefinitionInAnonymousNamespaceCheck.h
clang::tidy::readability::IsolateDeclarationCheck
This check diagnoses all DeclStmt's declaring more than one variable and tries to refactor the code t...
Definition: IsolateDeclarationCheck.h:23
clang::tidy::readability::IdentifierNamingCheck
Checks for identifiers naming style mismatch.
Definition: IdentifierNamingCheck.h:36
clang::tidy::readability::AvoidConstParamsInDecls
Definition: AvoidConstParamsInDecls.h:20
clang::tidy::readability::NamedParameterCheck
Find functions with unnamed arguments.
Definition: NamedParameterCheck.h:29
clang::tidy::readability::X
static ClangTidyModuleRegistry::Add< ReadabilityModule > X("readability-module", "Adds readability-related checks.")
MisleadingIndentationCheck.h
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
RedundantControlFlowCheck.h
MagicNumbersCheck.h
ElseAfterReturnCheck.h
NonConstParameterCheck.h
clang::tidy::readability::FunctionCognitiveComplexityCheck
Checks function Cognitive Complexity metric.
Definition: FunctionCognitiveComplexityCheck.h:34
clang::tidy::readability::QualifiedAutoCheck
Finds variables declared as auto that could be declared as: 'auto*' or 'const auto *' and reference v...
Definition: QualifiedAutoCheck.h:24
clang::tidy::readability::UniqueptrDeleteReleaseCheck
Flags statements of the form delete <unique_ptr expr>.release(); and replaces them with: <unique_ptr ...
Definition: UniqueptrDeleteReleaseCheck.h:23
clang::tidy::readability::RedundantPreprocessorCheck
This check flags redundant preprocessor directives: nested directives with the same condition.
Definition: RedundantPreprocessorCheck.h:23
clang::tidy::readability::RedundantAccessSpecifiersCheck
Detects redundant access specifiers inside classes, structs, and unions.
Definition: RedundantAccessSpecifiersCheck.h:22
UppercaseLiteralSuffixCheck.h
clang::tidy::readability::ContainerDataPointerCheck
Checks whether a call to operator[] and & can be replaced with a call to data().
Definition: ContainerDataPointerCheck.h:25
MakeMemberFunctionConstCheck.h
clang::tidy::readability::DeleteNullPointerCheck
Check whether the 'if' statement is unnecessary before calling 'delete' on a pointer.
Definition: DeleteNullPointerCheck.h:23
clang::tidy::readability::ImplicitBoolConversionCheck
Checks for use of implicit bool conversions in expressions.
Definition: ImplicitBoolConversionCheck.h:22
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:81
clang::tidy::readability::ConstReturnTypeCheck
For any function whose return type is const-qualified, suggests removal of the const qualifier from t...
Definition: ConstReturnTypeCheck.h:23
RedundantMemberInitCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
FunctionSizeCheck.h
clang::tidy::readability::StaticDefinitionInAnonymousNamespaceCheck
Finds static function and variable definitions in anonymous namespace.
Definition: StaticDefinitionInAnonymousNamespaceCheck.h:22