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"
12 #include "AvoidConstParamsInDecls.h"
13 #include "BracesAroundStatementsCheck.h"
14 #include "ConstReturnTypeCheck.h"
15 #include "ContainerSizeEmptyCheck.h"
16 #include "ConvertMemberFunctionsToStatic.h"
17 #include "DeleteNullPointerCheck.h"
18 #include "DeletedDefaultCheck.h"
19 #include "ElseAfterReturnCheck.h"
20 #include "FunctionCognitiveComplexityCheck.h"
21 #include "FunctionSizeCheck.h"
22 #include "IdentifierNamingCheck.h"
23 #include "ImplicitBoolConversionCheck.h"
24 #include "InconsistentDeclarationParameterNameCheck.h"
25 #include "IsolateDeclarationCheck.h"
26 #include "MagicNumbersCheck.h"
27 #include "MakeMemberFunctionConstCheck.h"
28 #include "MisleadingIndentationCheck.h"
29 #include "MisplacedArrayIndexCheck.h"
30 #include "NamedParameterCheck.h"
31 #include "NonConstParameterCheck.h"
32 #include "QualifiedAutoCheck.h"
33 #include "RedundantAccessSpecifiersCheck.h"
34 #include "RedundantControlFlowCheck.h"
35 #include "RedundantDeclarationCheck.h"
36 #include "RedundantFunctionPtrDereferenceCheck.h"
37 #include "RedundantMemberInitCheck.h"
38 #include "RedundantPreprocessorCheck.h"
39 #include "RedundantSmartptrGetCheck.h"
40 #include "RedundantStringCStrCheck.h"
41 #include "RedundantStringInitCheck.h"
42 #include "SimplifyBooleanExprCheck.h"
43 #include "SimplifySubscriptExprCheck.h"
44 #include "StaticAccessedThroughInstanceCheck.h"
45 #include "StaticDefinitionInAnonymousNamespaceCheck.h"
46 #include "StringCompareCheck.h"
47 #include "UniqueptrDeleteReleaseCheck.h"
48 #include "UppercaseLiteralSuffixCheck.h"
49 #include "UseAnyOfAllOfCheck.h"
50 
51 namespace clang {
52 namespace tidy {
53 namespace readability {
54 
55 class ReadabilityModule : public ClangTidyModule {
56 public:
addCheckFactories(ClangTidyCheckFactories & CheckFactories)57   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
58     CheckFactories.registerCheck<AvoidConstParamsInDecls>(
59         "readability-avoid-const-params-in-decls");
60     CheckFactories.registerCheck<BracesAroundStatementsCheck>(
61         "readability-braces-around-statements");
62     CheckFactories.registerCheck<ConstReturnTypeCheck>(
63         "readability-const-return-type");
64     CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
65         "readability-container-size-empty");
66     CheckFactories.registerCheck<ConvertMemberFunctionsToStatic>(
67         "readability-convert-member-functions-to-static");
68     CheckFactories.registerCheck<DeleteNullPointerCheck>(
69         "readability-delete-null-pointer");
70     CheckFactories.registerCheck<DeletedDefaultCheck>(
71         "readability-deleted-default");
72     CheckFactories.registerCheck<ElseAfterReturnCheck>(
73         "readability-else-after-return");
74     CheckFactories.registerCheck<FunctionCognitiveComplexityCheck>(
75         "readability-function-cognitive-complexity");
76     CheckFactories.registerCheck<FunctionSizeCheck>(
77         "readability-function-size");
78     CheckFactories.registerCheck<IdentifierNamingCheck>(
79         "readability-identifier-naming");
80     CheckFactories.registerCheck<ImplicitBoolConversionCheck>(
81         "readability-implicit-bool-conversion");
82     CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>(
83         "readability-inconsistent-declaration-parameter-name");
84     CheckFactories.registerCheck<IsolateDeclarationCheck>(
85         "readability-isolate-declaration");
86     CheckFactories.registerCheck<MagicNumbersCheck>(
87         "readability-magic-numbers");
88     CheckFactories.registerCheck<MakeMemberFunctionConstCheck>(
89         "readability-make-member-function-const");
90     CheckFactories.registerCheck<MisleadingIndentationCheck>(
91         "readability-misleading-indentation");
92     CheckFactories.registerCheck<MisplacedArrayIndexCheck>(
93         "readability-misplaced-array-index");
94     CheckFactories.registerCheck<QualifiedAutoCheck>(
95         "readability-qualified-auto");
96     CheckFactories.registerCheck<RedundantAccessSpecifiersCheck>(
97         "readability-redundant-access-specifiers");
98     CheckFactories.registerCheck<RedundantFunctionPtrDereferenceCheck>(
99         "readability-redundant-function-ptr-dereference");
100     CheckFactories.registerCheck<RedundantMemberInitCheck>(
101         "readability-redundant-member-init");
102     CheckFactories.registerCheck<RedundantPreprocessorCheck>(
103         "readability-redundant-preprocessor");
104     CheckFactories.registerCheck<SimplifySubscriptExprCheck>(
105         "readability-simplify-subscript-expr");
106     CheckFactories.registerCheck<StaticAccessedThroughInstanceCheck>(
107         "readability-static-accessed-through-instance");
108     CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>(
109         "readability-static-definition-in-anonymous-namespace");
110     CheckFactories.registerCheck<StringCompareCheck>(
111         "readability-string-compare");
112     CheckFactories.registerCheck<readability::NamedParameterCheck>(
113         "readability-named-parameter");
114     CheckFactories.registerCheck<NonConstParameterCheck>(
115         "readability-non-const-parameter");
116     CheckFactories.registerCheck<RedundantControlFlowCheck>(
117         "readability-redundant-control-flow");
118     CheckFactories.registerCheck<RedundantDeclarationCheck>(
119         "readability-redundant-declaration");
120     CheckFactories.registerCheck<RedundantSmartptrGetCheck>(
121         "readability-redundant-smartptr-get");
122     CheckFactories.registerCheck<RedundantStringCStrCheck>(
123         "readability-redundant-string-cstr");
124     CheckFactories.registerCheck<RedundantStringInitCheck>(
125         "readability-redundant-string-init");
126     CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
127         "readability-simplify-boolean-expr");
128     CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(
129         "readability-uniqueptr-delete-release");
130     CheckFactories.registerCheck<UppercaseLiteralSuffixCheck>(
131         "readability-uppercase-literal-suffix");
132     CheckFactories.registerCheck<UseAnyOfAllOfCheck>(
133         "readability-use-anyofallof");
134   }
135 };
136 
137 // Register the ReadabilityModule using this statically initialized variable.
138 static ClangTidyModuleRegistry::Add<ReadabilityModule>
139     X("readability-module", "Adds readability-related checks.");
140 
141 } // namespace readability
142 
143 // This anchor is used to force the linker to link in the generated object file
144 // and thus register the ReadabilityModule.
145 volatile int ReadabilityModuleAnchorSource = 0;
146 
147 } // namespace tidy
148 } // namespace clang
149