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