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 "ContainerSizeEmptyCheck.h"
16 #include "DeletedDefaultCheck.h"
17 #include "ElseAfterReturnCheck.h"
18 #include "FunctionSizeCheck.h"
19 #include "IdentifierNamingCheck.h"
20 #include "ImplicitBoolCastCheck.h"
21 #include "InconsistentDeclarationParameterNameCheck.h"
22 #include "MisplacedArrayIndexCheck.h"
23 #include "NamedParameterCheck.h"
24 #include "NonConstParameterCheck.h"
25 #include "RedundantControlFlowCheck.h"
26 #include "RedundantMemberInitCheck.h"
27 #include "RedundantSmartptrGetCheck.h"
28 #include "RedundantStringCStrCheck.h"
29 #include "RedundantStringInitCheck.h"
30 #include "SimplifyBooleanExprCheck.h"
31 #include "StaticDefinitionInAnonymousNamespaceCheck.h"
32 #include "UniqueptrDeleteReleaseCheck.h"
33 
34 namespace clang {
35 namespace tidy {
36 namespace readability {
37 
38 class ReadabilityModule : public ClangTidyModule {
39 public:
40   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
41     CheckFactories.registerCheck<AvoidConstParamsInDecls>(
42         "readability-avoid-const-params-in-decls");
43     CheckFactories.registerCheck<BracesAroundStatementsCheck>(
44         "readability-braces-around-statements");
45     CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
46         "readability-container-size-empty");
47     CheckFactories.registerCheck<DeletedDefaultCheck>(
48         "readability-deleted-default");
49     CheckFactories.registerCheck<ElseAfterReturnCheck>(
50         "readability-else-after-return");
51     CheckFactories.registerCheck<FunctionSizeCheck>(
52         "readability-function-size");
53     CheckFactories.registerCheck<IdentifierNamingCheck>(
54         "readability-identifier-naming");
55     CheckFactories.registerCheck<ImplicitBoolCastCheck>(
56         "readability-implicit-bool-cast");
57     CheckFactories.registerCheck<InconsistentDeclarationParameterNameCheck>(
58         "readability-inconsistent-declaration-parameter-name");
59     CheckFactories.registerCheck<MisplacedArrayIndexCheck>(
60         "readability-misplaced-array-index");
61     CheckFactories.registerCheck<RedundantMemberInitCheck>(
62         "readability-redundant-member-init");
63     CheckFactories.registerCheck<StaticDefinitionInAnonymousNamespaceCheck>(
64         "readability-static-definition-in-anonymous-namespace");
65     CheckFactories.registerCheck<readability::NamedParameterCheck>(
66         "readability-named-parameter");
67     CheckFactories.registerCheck<NonConstParameterCheck>(
68         "readability-non-const-parameter");
69     CheckFactories.registerCheck<RedundantControlFlowCheck>(
70         "readability-redundant-control-flow");
71     CheckFactories.registerCheck<RedundantSmartptrGetCheck>(
72         "readability-redundant-smartptr-get");
73     CheckFactories.registerCheck<RedundantStringCStrCheck>(
74         "readability-redundant-string-cstr");
75     CheckFactories.registerCheck<RedundantStringInitCheck>(
76         "readability-redundant-string-init");
77     CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
78         "readability-simplify-boolean-expr");
79     CheckFactories.registerCheck<UniqueptrDeleteReleaseCheck>(
80         "readability-uniqueptr-delete-release");
81   }
82 };
83 
84 // Register the ReadabilityModule using this statically initialized variable.
85 static ClangTidyModuleRegistry::Add<ReadabilityModule>
86     X("readability-module", "Adds readability-related checks.");
87 
88 } // namespace readability
89 
90 // This anchor is used to force the linker to link in the generated object file
91 // and thus register the ReadabilityModule.
92 volatile int ReadabilityModuleAnchorSource = 0;
93 
94 } // namespace tidy
95 } // namespace clang
96