clang-tools  5.0.0
ReadabilityTidyModule.cpp
Go to the documentation of this file.
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"
16 #include "DeleteNullPointerCheck.h"
17 #include "DeletedDefaultCheck.h"
18 #include "ElseAfterReturnCheck.h"
19 #include "FunctionSizeCheck.h"
20 #include "IdentifierNamingCheck.h"
21 #include "ImplicitBoolCastCheck.h"
25 #include "NamedParameterCheck.h"
26 #include "NonConstParameterCheck.h"
37 
38 namespace clang {
39 namespace tidy {
40 namespace readability {
41 
43 public:
44  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
45  CheckFactories.registerCheck<AvoidConstParamsInDecls>(
46  "readability-avoid-const-params-in-decls");
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");
64  "readability-inconsistent-declaration-parameter-name");
66  "readability-misleading-indentation");
68  "readability-misplaced-array-index");
70  "readability-redundant-function-ptr-dereference");
72  "readability-redundant-member-init");
74  "readability-static-definition-in-anonymous-namespace");
76  "readability-named-parameter");
77  CheckFactories.registerCheck<NonConstParameterCheck>(
78  "readability-non-const-parameter");
80  "readability-redundant-control-flow");
82  "readability-redundant-declaration");
84  "readability-redundant-smartptr-get");
86  "readability-redundant-string-cstr");
88  "readability-redundant-string-init");
90  "readability-simplify-boolean-expr");
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.
105 
106 } // namespace tidy
107 } // namespace clang
static ClangTidyModuleRegistry::Add< ReadabilityModule > X("readability-module","Adds readability-related checks.")
volatile int ReadabilityModuleAnchorSource
Finds member initializations that are unnecessary because the same default constructor would be calle...
Checks when a constructor or an assignment operator is marked as '= default' but is actually deleted ...
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Finds static function and variable definitions in anonymous namespace.
Check whether the 'if' statement is unnecessary before calling 'delete' on a pointer.
Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate ...
Checks whether a call to the size() method can be replaced with a call to empty().
A collection of ClangTidyCheckFactory instances.
Flags the usages of else after return.
Checks for large functions based on various metrics.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Warn when a pointer function parameter can be const.
Finds unnecessary string initializations.
Find and remove redundant calls to smart pointer's .get() method.
Warn about unusual array index syntax (index[array] instead of array[index]).
Checks for declarations of functions which differ in parameter names.
Find functions with unnamed arguments.
Flags statements of the form delete <unique_ptr expr>.release(); and replaces them with: <unique_ptr ...
Finds unnecessary calls to std::string::c_str().
Checks the code for dangling else, and possible misleading indentations due to missing braces...
Checks for use of implicit bool casts in expressions.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
Eliminates redundant return statements at the end of a function that returns void.
Checks for identifiers naming style mismatch.