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