clang-tools  6.0.0
MiscTidyModule.cpp
Go to the documentation of this file.
1 //===--- MiscTidyModule.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"
15 #include "IncorrectRoundings.h"
17 #include "MacroParenthesesCheck.h"
19 #include "MisplacedConstCheck.h"
22 #include "NonCopyableObjects.h"
24 #include "SizeofContainerCheck.h"
25 #include "SizeofExpressionCheck.h"
26 #include "StaticAssertCheck.h"
27 #include "StringCompareCheck.h"
34 #include "SwappedArgumentsCheck.h"
37 #include "UndelegatedConstructor.h"
39 #include "UnusedAliasDeclsCheck.h"
40 #include "UnusedParametersCheck.h"
41 #include "UnusedRAIICheck.h"
42 #include "UnusedUsingDeclsCheck.h"
43 
44 namespace clang {
45 namespace tidy {
46 namespace misc {
47 
48 class MiscModule : public ClangTidyModule {
49 public:
50  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
52  "misc-forwarding-reference-overload");
53  CheckFactories.registerCheck<LambdaFunctionNameCheck>(
54  "misc-lambda-function-name");
55  CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
57  "misc-unconventional-assign-operator");
59  "misc-definitions-in-headers");
60  CheckFactories.registerCheck<IncorrectRoundings>(
61  "misc-incorrect-roundings");
62  CheckFactories.registerCheck<MacroParenthesesCheck>(
63  "misc-macro-parentheses");
65  "misc-macro-repeated-side-effects");
67  "misc-misplaced-widening-cast");
68  CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
69  "misc-new-delete-overloads");
70  CheckFactories.registerCheck<NonCopyableObjectsCheck>(
71  "misc-non-copyable-objects");
73  "misc-redundant-expression");
74  CheckFactories.registerCheck<SizeofContainerCheck>("misc-sizeof-container");
75  CheckFactories.registerCheck<SizeofExpressionCheck>(
76  "misc-sizeof-expression");
77  CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert");
78  CheckFactories.registerCheck<StringCompareCheck>("misc-string-compare");
80  "misc-string-integer-assignment");
82  "misc-string-literal-with-embedded-nul");
84  "misc-suspicious-enum-usage");
86  "misc-suspicious-missing-comma");
88  "misc-suspicious-semicolon");
90  "misc-suspicious-string-compare");
91  CheckFactories.registerCheck<SwappedArgumentsCheck>(
92  "misc-swapped-arguments");
94  "misc-throw-by-value-catch-by-reference");
96  "misc-undelegated-constructor");
98  "misc-uniqueptr-reset-release");
99  CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
100  "misc-unused-alias-decls");
101  CheckFactories.registerCheck<UnusedParametersCheck>(
102  "misc-unused-parameters");
103  CheckFactories.registerCheck<UnusedRAIICheck>("misc-unused-raii");
104  CheckFactories.registerCheck<UnusedUsingDeclsCheck>(
105  "misc-unused-using-decls");
106  }
107 };
108 
109 } // namespace misc
110 
111 // Register the MiscTidyModule using this statically initialized variable.
112 static ClangTidyModuleRegistry::Add<misc::MiscModule>
113  X("misc-module", "Adds miscellaneous lint checks.");
114 
115 // This anchor is used to force the linker to link in the generated object file
116 // and thus register the MiscModule.
117 volatile int MiscModuleAnchorSource = 0;
118 
119 } // namespace tidy
120 } // namespace clang
This check diagnoses when a const qualifier is applied to a typedef to a pointer type rather than to ...
Finds instances where an integer is assigned to a string.
Checks for repeated argument with side effects in macros.
Finds potentially swapped arguments by looking at implicit conversions.
Find and replace unique_ptr::reset(release()) with std::move().
checks for locations that do not throw by value
Finds temporaries that look like RAII objects.
Finds creation of temporary objects in constructors that look like a function call to another constru...
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Finds unused namespace alias declarations.
Find suspicious calls to string compare functions.
Checks the usage of patterns known to produce incorrect rounding.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
A collection of ClangTidyCheckFactory instances.
Finds unused using declarations.
Find suspicious string literals with embedded NUL characters.
This check finds string literals which are probably concatenated accidentally.
Find suspicious usages of sizeof expression.
Finds macros that can have unexpected behaviour due to missing parentheses.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
Detect when func or FUNCTION is being used from within a lambda.
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
Find casts of calculation results to bigger type.
The checker detects expressions that are redundant, because they contain ineffective, useless parts.
This check flags all calls compare when used to check for string equality or inequality.
The checker looks for constructors that can act as copy or move constructors through their forwarding...
The checker detects various cases when an enum is probably misused (as a bitmask).
volatile int MiscModuleAnchorSource
Find usages of sizeof on expressions of STL container types.
Finds non-extern non-inline function and variable definitions in header files, which can lead to pote...
Finds declarations of assignment operators with the wrong return and/or argument types and definition...
Finds unused parameters and fixes them, so that -Wunused-parameter can be turned on.
This check finds semicolon that modifies the meaning of the program unintendedly. ...