clang-tools  9.0.0
ReadabilityTidyModule.cpp
Go to the documentation of this file.
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"
14 #include "ConstReturnTypeCheck.h"
17 #include "DeleteNullPointerCheck.h"
18 #include "DeletedDefaultCheck.h"
19 #include "ElseAfterReturnCheck.h"
20 #include "FunctionSizeCheck.h"
21 #include "IdentifierNamingCheck.h"
25 #include "MagicNumbersCheck.h"
28 #include "NamedParameterCheck.h"
29 #include "NonConstParameterCheck.h"
42 #include "StringCompareCheck.h"
45 
46 namespace clang {
47 namespace tidy {
48 namespace readability {
49 
51 public:
52  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
53  CheckFactories.registerCheck<AvoidConstParamsInDecls>(
54  "readability-avoid-const-params-in-decls");
56  "readability-braces-around-statements");
57  CheckFactories.registerCheck<ConstReturnTypeCheck>(
58  "readability-const-return-type");
59  CheckFactories.registerCheck<ContainerSizeEmptyCheck>(
60  "readability-container-size-empty");
62  "readability-convert-member-functions-to-static");
63  CheckFactories.registerCheck<DeleteNullPointerCheck>(
64  "readability-delete-null-pointer");
65  CheckFactories.registerCheck<DeletedDefaultCheck>(
66  "readability-deleted-default");
67  CheckFactories.registerCheck<ElseAfterReturnCheck>(
68  "readability-else-after-return");
69  CheckFactories.registerCheck<FunctionSizeCheck>(
70  "readability-function-size");
71  CheckFactories.registerCheck<IdentifierNamingCheck>(
72  "readability-identifier-naming");
74  "readability-implicit-bool-conversion");
76  "readability-inconsistent-declaration-parameter-name");
77  CheckFactories.registerCheck<IsolateDeclarationCheck>(
78  "readability-isolate-declaration");
79  CheckFactories.registerCheck<MagicNumbersCheck>(
80  "readability-magic-numbers");
82  "readability-misleading-indentation");
84  "readability-misplaced-array-index");
86  "readability-redundant-function-ptr-dereference");
88  "readability-redundant-member-init");
90  "readability-redundant-preprocessor");
92  "readability-simplify-subscript-expr");
94  "readability-static-accessed-through-instance");
96  "readability-static-definition-in-anonymous-namespace");
97  CheckFactories.registerCheck<StringCompareCheck>(
98  "readability-string-compare");
100  "readability-named-parameter");
101  CheckFactories.registerCheck<NonConstParameterCheck>(
102  "readability-non-const-parameter");
104  "readability-redundant-control-flow");
106  "readability-redundant-declaration");
108  "readability-redundant-smartptr-get");
109  CheckFactories.registerCheck<RedundantStringCStrCheck>(
110  "readability-redundant-string-cstr");
111  CheckFactories.registerCheck<RedundantStringInitCheck>(
112  "readability-redundant-string-init");
113  CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
114  "readability-simplify-boolean-expr");
116  "readability-uniqueptr-delete-release");
118  "readability-uppercase-literal-suffix");
119  }
120 };
121 
122 // Register the ReadabilityModule using this statically initialized variable.
123 static ClangTidyModuleRegistry::Add<ReadabilityModule>
124  X("readability-module", "Adds readability-related checks.");
125 
126 } // namespace readability
127 
128 // This anchor is used to force the linker to link in the generated object file
129 // and thus register the ReadabilityModule.
131 
132 } // namespace tidy
133 } // namespace clang
Detects when the integral literal or floating point literal has non-uppercase suffix, and suggests to make the suffix uppercase.
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 &#39;= default&#39; 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 &#39;if&#39; statement is unnecessary before calling &#39;delete&#39; 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.
static ClangTidyModuleRegistry::Add< ReadabilityModule > X("readability-module", "Adds readability-related checks.")
This check diagnoses all DeclStmt&#39;s declaring more than one variable and tries to refactor the code t...
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.
Detects magic numbers, integer and floating point literals embedded in code.
This check flags redundant preprocessor directives: nested directives with the same condition...
Finds unnecessary string initializations.
Find and remove redundant calls to smart pointer&#39;s .get() method.
Warn about unusual array index syntax (index[array] instead of array[index]).
@brief Checks for member expressions that access static members through instances and replaces them w...
This check finds C++ class methods than can be made static because they don&#39;t use the &#39;this&#39; pointer...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Checks for use of implicit bool conversions in expressions.
Checks for declarations of functions which differ in parameter names.
Find functions with unnamed arguments.
This check flags all calls compare when used to check for string equality or inequality.
Flags statements of the form delete <unique_ptr expr>.release(); and replaces them with: <unique_ptr ...
Finds unnecessary calls to std::string::c_str().
For any function whose return type is const-qualified, suggests removal of the const qualifier from t...
Checks the code for dangling else, and possible misleading indentations due to missing braces...
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.