clang-tools  11.0.0
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"
17 #include "DeleteNullPointerCheck.h"
18 #include "DeletedDefaultCheck.h"
19 #include "ElseAfterReturnCheck.h"
20 #include "FunctionSizeCheck.h"
21 #include "IdentifierNamingCheck.h"
25 #include "MagicNumbersCheck.h"
29 #include "NamedParameterCheck.h"
30 #include "NonConstParameterCheck.h"
31 #include "QualifiedAutoCheck.h"
45 #include "StringCompareCheck.h"
48 #include "UseAnyOfAllOfCheck.h"
49 
50 namespace clang {
51 namespace tidy {
52 namespace readability {
53 
55 public:
56  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
57  CheckFactories.registerCheck<AvoidConstParamsInDecls>(
58  "readability-avoid-const-params-in-decls");
60  "readability-braces-around-statements");
61  CheckFactories.registerCheck<ConstReturnTypeCheck>(
62  "readability-const-return-type");
63  CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
64  "readability-container-size-empty");
66  "readability-convert-member-functions-to-static");
67  CheckFactories.registerCheck<DeleteNullPointerCheck>(
68  "readability-delete-null-pointer");
69  CheckFactories.registerCheck<DeletedDefaultCheck>(
70  "readability-deleted-default");
71  CheckFactories.registerCheck<ElseAfterReturnCheck>(
72  "readability-else-after-return");
73  CheckFactories.registerCheck<FunctionSizeCheck>(
74  "readability-function-size");
75  CheckFactories.registerCheck<IdentifierNamingCheck>(
76  "readability-identifier-naming");
78  "readability-implicit-bool-conversion");
80  "readability-inconsistent-declaration-parameter-name");
81  CheckFactories.registerCheck<IsolateDeclarationCheck>(
82  "readability-isolate-declaration");
83  CheckFactories.registerCheck<MagicNumbersCheck>(
84  "readability-magic-numbers");
86  "readability-make-member-function-const");
88  "readability-misleading-indentation");
90  "readability-misplaced-array-index");
91  CheckFactories.registerCheck<QualifiedAutoCheck>(
92  "readability-qualified-auto");
94  "readability-redundant-access-specifiers");
96  "readability-redundant-function-ptr-dereference");
98  "readability-redundant-member-init");
100  "readability-redundant-preprocessor");
102  "readability-simplify-subscript-expr");
104  "readability-static-accessed-through-instance");
106  "readability-static-definition-in-anonymous-namespace");
107  CheckFactories.registerCheck<StringCompareCheck>(
108  "readability-string-compare");
110  "readability-named-parameter");
111  CheckFactories.registerCheck<NonConstParameterCheck>(
112  "readability-non-const-parameter");
114  "readability-redundant-control-flow");
116  "readability-redundant-declaration");
118  "readability-redundant-smartptr-get");
119  CheckFactories.registerCheck<RedundantStringCStrCheck>(
120  "readability-redundant-string-cstr");
121  CheckFactories.registerCheck<RedundantStringInitCheck>(
122  "readability-redundant-string-init");
123  CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
124  "readability-simplify-boolean-expr");
126  "readability-uniqueptr-delete-release");
128  "readability-uppercase-literal-suffix");
129  CheckFactories.registerCheck<UseAnyOfAllOfCheck>(
130  "readability-use-anyofallof");
131  }
132 };
133 
134 // Register the ReadabilityModule using this statically initialized variable.
135 static ClangTidyModuleRegistry::Add<ReadabilityModule>
136  X("readability-module", "Adds readability-related checks.");
137 
138 } // namespace readability
139 
140 // This anchor is used to force the linker to link in the generated object file
141 // and thus register the ReadabilityModule.
143 
144 } // namespace tidy
145 } // namespace clang
ImplicitBoolConversionCheck.h
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:142
AvoidConstParamsInDecls.h
IsolateDeclarationCheck.h
InconsistentDeclarationParameterNameCheck.h
clang::tidy::readability::DeletedDefaultCheck
Checks when a constructor or an assignment operator is marked as '= default' but is actually deleted ...
Definition: DeletedDefaultCheck.h:23
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
DeletedDefaultCheck.h
RedundantStringInitCheck.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:30
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:56
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
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
NamedParameterCheck.h
RedundantSmartptrGetCheck.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
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:25
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:54
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:25
RedundantPreprocessorCheck.h
clang::tidy::readability::ElseAfterReturnCheck
Flags the usages of else after return.
Definition: ElseAfterReturnCheck.h:21
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:33
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::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
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:83
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:61
FunctionSizeCheck.h
clang::tidy::readability::StaticDefinitionInAnonymousNamespaceCheck
Finds static function and variable definitions in anonymous namespace.
Definition: StaticDefinitionInAnonymousNamespaceCheck.h:22