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