clang-tools 6.0.0

ReadabilityTidyModule.cpp
Go to the documentation of this file.
1 //===--- ReadabilityTidyModule.cpp - clang-tidy ---------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "../ClangTidy.h"
11 #include "../ClangTidyModule.h"
12 #include "../ClangTidyModuleRegistry.h"
13 #include "AvoidConstParamsInDecls.h"
14 #include "BracesAroundStatementsCheck.h"
15 #include "ContainerSizeEmptyCheck.h"
16 #include "DeleteNullPointerCheck.h"
17 #include "DeletedDefaultCheck.h"
18 #include "ElseAfterReturnCheck.h"
19 #include "FunctionSizeCheck.h"
20 #include "IdentifierNamingCheck.h"
21 #include "ImplicitBoolConversionCheck.h"
22 #include "InconsistentDeclarationParameterNameCheck.h"
23 #include "MisleadingIndentationCheck.h"
24 #include "MisplacedArrayIndexCheck.h"
25 #include "NamedParameterCheck.h"
26 #include "NonConstParameterCheck.h"
27 #include "RedundantControlFlowCheck.h"
28 #include "RedundantDeclarationCheck.h"
29 #include "RedundantFunctionPtrDereferenceCheck.h"
30 #include "RedundantMemberInitCheck.h"
31 #include "RedundantSmartptrGetCheck.h"
32 #include "RedundantStringCStrCheck.h"
33 #include "RedundantStringInitCheck.h"
34 #include "SimplifyBooleanExprCheck.h"
35 #include "StaticAccessedThroughInstanceCheck.h"
36 #include "StaticDefinitionInAnonymousNamespaceCheck.h"
37 #include "UniqueptrDeleteReleaseCheck.h"
38
39 namespace clang {
40 namespace tidy {
41 namespace readability {
42
43 class ReadabilityModule : public ClangTidyModule {
44 public:
45 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
46 CheckFactories.registerCheck<AvoidConstParamsInDecls>(
47 "readability-avoid-const-params-in-decls");
48 CheckFactories.registerCheck<BracesAroundStatementsCheck>(
49 "readability-braces-around-statements");
50 CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
51 "readability-container-size-empty");
52 CheckFactories.registerCheck<DeleteNullPointerCheck>(
53 "readability-delete-null-pointer");
54 CheckFactories.registerCheck<DeletedDefaultCheck>(
55 "readability-deleted-default");
56 CheckFactories.registerCheck<ElseAfterReturnCheck>(
57 "readability-else-after-return");
58 CheckFactories.registerCheck<FunctionSizeCheck>(
59 "readability-function-size");
60 CheckFactories.registerCheck<IdentifierNamingCheck>(
61 "readability-identifier-naming");
62 CheckFactories.registerCheck<ImplicitBoolConversionCheck>(
63 "readability-implicit-bool-conversion");
64 CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>(
65 "readability-inconsistent-declaration-parameter-name");
66 CheckFactories.registerCheck<MisleadingIndentationCheck>(
67 "readability-misleading-indentation");
68 CheckFactories.registerCheck<MisplacedArrayIndexCheck>(
69 "readability-misplaced-array-index");
70 CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>(
71 "readability-redundant-function-ptr-dereference");
72 CheckFactories.registerCheck<RedundantMemberInitCheck>(
73 "readability-redundant-member-init");
74 CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>(
75 "readability-static-accessed-through-instance");
76 CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>(
77 "readability-static-definition-in-anonymous-namespace");
78 CheckFactories.registerCheck<readability::NamedParameterCheck>(
79 "readability-named-parameter");
80 CheckFactories.registerCheck<NonConstParameterCheck>(
81 "readability-non-const-parameter");
82 CheckFactories.registerCheck<RedundantControlFlowCheck>(
83 "readability-redundant-control-flow");
84 CheckFactories.registerCheck<RedundantDeclarationCheck>(
85 "readability-redundant-declaration");
86 CheckFactories.registerCheck<RedundantSmartptrGetCheck>(
87 "readability-redundant-smartptr-get");
88 CheckFactories.registerCheck<RedundantStringCStrCheck>(
89 "readability-redundant-string-cstr");
90 CheckFactories.registerCheck<RedundantStringInitCheck>(
91 "readability-redundant-string-init");
92 CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
93 "readability-simplify-boolean-expr");
94 CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(
95 "readability-uniqueptr-delete-release");
96 }
97 };
98
99 // Register the ReadabilityModule using this statically initialized variable.
100 static ClangTidyModuleRegistry::Add<ReadabilityModule>
101 X("readability-module", "Adds readability-related checks.");
102
103 } // namespace readability
104
105 // This anchor is used to force the linker to link in the generated object file
106 // and thus register the ReadabilityModule.
107 volatile int ReadabilityModuleAnchorSource = 0;
108
109 } // namespace tidy
110 } // namespace clang
MisleadingIndentationCheck.h
MisplacedArrayIndexCheck.h
clang::tidy::ReadabilityModuleAnchorSource
volatile int ReadabilityModuleAnchorSource
Definition: ReadabilityTidyModule.cpp:107
clang::tidy::readability::RedundantMemberInitCheck
Finds member initializations that are unnecessary because the same default constructor would be calle...
Definition: RedundantMemberInitCheck.h:24
clang::tidy::readability::DeletedDefaultCheck
Checks when a constructor or an assignment operator is marked as &#39;= default&#39; but is actually deleted ...
Definition: DeletedDefaultCheck.h:24
NonConstParameterCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
RedundantControlFlowCheck.h
InconsistentDeclarationParameterNameCheck.h
SimplifyBooleanExprCheck.h
clang::tidy::readability::StaticDefinitionInAnonymousNamespaceCheck
Finds static function and variable definitions in anonymous namespace.
Definition: StaticDefinitionInAnonymousNamespaceCheck.h:23
clang::tidy::readability::DeleteNullPointerCheck
Check whether the &#39;if&#39; statement is unnecessary before calling &#39;delete&#39; on a pointer.
Definition: DeleteNullPointerCheck.h:24
clang::tidy::readability::SimplifyBooleanExprCheck
Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate ...
Definition: SimplifyBooleanExprCheck.h:24
clang::tidy::readability::ContainerSizeEmptyCheck
Checks whether a call to the size() method can be replaced with a call to empty().
Definition: ContainerSizeEmptyCheck.h:29
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::readability::ReadabilityModule
Definition: ReadabilityTidyModule.cpp:43
UniqueptrDeleteReleaseCheck.h
clang::tidy::readability::ElseAfterReturnCheck
Flags the usages of else after return.
Definition: ElseAfterReturnCheck.h:22
clang::tidy::readability::X
static ClangTidyModuleRegistry::Add< ReadabilityModule > X("readability-module", "Adds readability-related checks.")
RedundantStringCStrCheck.h
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition: FunctionSizeCheck.h:36
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
DeletedDefaultCheck.h
clang::tidy::readability::NonConstParameterCheck
Warn when a pointer function parameter can be const.
Definition: NonConstParameterCheck.h:23
clang::tidy::readability::RedundantStringInitCheck
Finds unnecessary string initializations.
Definition: RedundantStringInitCheck.h:20
clang::tidy::readability::RedundantSmartptrGetCheck
Find and remove redundant calls to smart pointer&#39;s .get() method.
Definition: RedundantSmartptrGetCheck.h:28
clang::tidy::readability::MisplacedArrayIndexCheck
Warn about unusual array index syntax (index[array] instead of array[index]).
Definition: MisplacedArrayIndexCheck.h:24
RedundantFunctionPtrDereferenceCheck.h
clang::tidy::readability::StaticAccessedThroughInstanceCheck
@brief Checks for member expressions that access static members through instances and replaces them w...
Definition: StaticAccessedThroughInstanceCheck.h:24
ElseAfterReturnCheck.h
NamedParameterCheck.h
RedundantMemberInitCheck.h
BracesAroundStatementsCheck.h
ImplicitBoolConversionCheck.h
StaticDefinitionInAnonymousNamespaceCheck.h
RedundantSmartptrGetCheck.h
clang
Definition: AndroidTidyModule.cpp:28
IdentifierNamingCheck.h
clang::tidy::readability::ImplicitBoolConversionCheck
Checks for use of implicit bool conversions in expressions.
Definition: ImplicitBoolConversionCheck.h:23
clang::tidy::readability::AvoidConstParamsInDecls
Definition: AvoidConstParamsInDecls.h:21
DeleteNullPointerCheck.h
clang::tidy::readability::InconsistentDeclarationParameterNameCheck
Checks for declarations of functions which differ in parameter names.
Definition: InconsistentDeclarationParameterNameCheck.h:26
clang::tidy::readability::NamedParameterCheck
Find functions with unnamed arguments.
Definition: NamedParameterCheck.h:30
RedundantDeclarationCheck.h
clang::tidy::readability::UniqueptrDeleteReleaseCheck
Flags statements of the form delete <unique_ptr expr>.release(); and replaces them with: <unique_ptr ...
Definition: UniqueptrDeleteReleaseCheck.h:24
AvoidConstParamsInDecls.h
clang::tidy::readability::RedundantStringCStrCheck
Finds unnecessary calls to std::string::c_str().
Definition: RedundantStringCStrCheck.h:20
FunctionSizeCheck.h
clang::tidy::readability::MisleadingIndentationCheck
Checks the code for dangling else, and possible misleading indentations due to missing braces...
Definition: MisleadingIndentationCheck.h:25
clang::tidy::readability::RedundantDeclarationCheck
Find redundant variable declarations.
Definition: RedundantDeclarationCheck.h:23
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:45
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:44
clang::tidy::readability::RedundantControlFlowCheck
Eliminates redundant return statements at the end of a function that returns void.
Definition: RedundantControlFlowCheck.h:26
RedundantStringInitCheck.h
clang::tidy::readability::RedundantFunctionPtrDereferenceCheck
Eliminate redundant dereferences of a function pointer.
Definition: RedundantFunctionPtrDereferenceCheck.h:23
StaticAccessedThroughInstanceCheck.h
clang::tidy::readability::IdentifierNamingCheck
Checks for identifiers naming style mismatch.
Definition: IdentifierNamingCheck.h:35
ContainerSizeEmptyCheck.h