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