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