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