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"
13 #include "DefinitionsInHeadersCheck.h"
14 #include "ForwardingReferenceOverloadCheck.h"
15 #include "IncorrectRoundings.h"
16 #include "LambdaFunctionNameCheck.h"
17 #include "MacroParenthesesCheck.h"
18 #include "MacroRepeatedSideEffectsCheck.h"
19 #include "MisplacedConstCheck.h"
20 #include "MisplacedWideningCastCheck.h"
21 #include "NewDeleteOverloadsCheck.h"
22 #include "NonCopyableObjects.h"
23 #include "RedundantExpressionCheck.h"
24 #include "SizeofContainerCheck.h"
25 #include "SizeofExpressionCheck.h"
26 #include "StaticAssertCheck.h"
27 #include "StringCompareCheck.h"
28 #include "StringIntegerAssignmentCheck.h"
29 #include "StringLiteralWithEmbeddedNulCheck.h"
30 #include "SuspiciousEnumUsageCheck.h"
31 #include "SuspiciousMissingCommaCheck.h"
32 #include "SuspiciousSemicolonCheck.h"
33 #include "SuspiciousStringCompareCheck.h"
34 #include "SwappedArgumentsCheck.h"
35 #include "ThrowByValueCatchByReferenceCheck.h"
36 #include "UnconventionalAssignOperatorCheck.h"
37 #include "UndelegatedConstructor.h"
38 #include "UniqueptrResetReleaseCheck.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 {
51 CheckFactories.registerCheck<ForwardingReferenceOverloadCheck>(
52 "misc-forwarding-reference-overload");
53 CheckFactories.registerCheck<LambdaFunctionNameCheck>(
54 "misc-lambda-function-name");
55 CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
56 CheckFactories.registerCheck<UnconventionalAssignOperatorCheck>(
57 "misc-unconventional-assign-operator");
58 CheckFactories.registerCheck<DefinitionsInHeadersCheck>(
59 "misc-definitions-in-headers");
60 CheckFactories.registerCheck<IncorrectRoundings>(
61 "misc-incorrect-roundings");
62 CheckFactories.registerCheck<MacroParenthesesCheck>(
63 "misc-macro-parentheses");
64 CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>(
65 "misc-macro-repeated-side-effects");
66 CheckFactories.registerCheck<MisplacedWideningCastCheck>(
67 "misc-misplaced-widening-cast");
68 CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
69 "misc-new-delete-overloads");
70 CheckFactories.registerCheck<NonCopyableObjectsCheck>(
71 "misc-non-copyable-objects");
72 CheckFactories.registerCheck<RedundantExpressionCheck>(
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");
79 CheckFactories.registerCheck<StringIntegerAssignmentCheck>(
80 "misc-string-integer-assignment");
81 CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>(
82 "misc-string-literal-with-embedded-nul");
83 CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
84 "misc-suspicious-enum-usage");
85 CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(
86 "misc-suspicious-missing-comma");
87 CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
88 "misc-suspicious-semicolon");
89 CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
90 "misc-suspicious-string-compare");
91 CheckFactories.registerCheck<SwappedArgumentsCheck>(
92 "misc-swapped-arguments");
93 CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
94 "misc-throw-by-value-catch-by-reference");
95 CheckFactories.registerCheck<UndelegatedConstructorCheck>(
96 "misc-undelegated-constructor");
97 CheckFactories.registerCheck<UniqueptrResetReleaseCheck>(
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
SuspiciousEnumUsageCheck.h
NonCopyableObjects.h
clang::tidy::misc::MisplacedConstCheck
This check diagnoses when a const qualifier is applied to a typedef to a pointer type rather than to ...
Definition: MisplacedConstCheck.h:24
UnconventionalAssignOperatorCheck.h
ThrowByValueCatchByReferenceCheck.h
clang::tidy::misc::StringIntegerAssignmentCheck
Finds instances where an integer is assigned to a string.
Definition: StringIntegerAssignmentCheck.h:23
clang::tidy::misc::MacroRepeatedSideEffectsCheck
Checks for repeated argument with side effects in macros.
Definition: MacroRepeatedSideEffectsCheck.h:20
clang::tidy::misc::SwappedArgumentsCheck
Finds potentially swapped arguments by looking at implicit conversions.
Definition: SwappedArgumentsCheck.h:20
ForwardingReferenceOverloadCheck.h
StaticAssertCheck.h
clang::tidy::misc::UniqueptrResetReleaseCheck
Find and replace unique_ptr::reset(release()) with std::move().
Definition: UniqueptrResetReleaseCheck.h:30
StringIntegerAssignmentCheck.h
MacroRepeatedSideEffectsCheck.h
clang::tidy::misc::ThrowByValueCatchByReferenceCheck
checks for locations that do not throw by value
Definition: ThrowByValueCatchByReferenceCheck.h:30
SwappedArgumentsCheck.h
clang::tidy::misc::UnusedRAIICheck
Finds temporaries that look like RAII objects.
Definition: UnusedRAIICheck.h:23
clang::tidy::misc::UndelegatedConstructorCheck
Finds creation of temporary objects in constructors that look like a function call to another constru...
Definition: UndelegatedConstructor.h:24
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::misc::StaticAssertCheck
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Definition: StaticAssertCheck.h:26
clang::tidy::misc::UnusedAliasDeclsCheck
Finds unused namespace alias declarations.
Definition: UnusedAliasDeclsCheck.h:21
clang::tidy::misc::SuspiciousStringCompareCheck
Find suspicious calls to string compare functions.
Definition: SuspiciousStringCompareCheck.h:23
RedundantExpressionCheck.h
clang::tidy::misc::IncorrectRoundings
Checks the usage of patterns known to produce incorrect rounding.
Definition: IncorrectRoundings.h:27
NewDeleteOverloadsCheck.h
clang::tidy::misc::MiscModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: MiscTidyModule.cpp:50
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::misc::MiscModule
Definition: MiscTidyModule.cpp:48
MisplacedConstCheck.h
SizeofExpressionCheck.h
clang::tidy::misc::UnusedUsingDeclsCheck
Finds unused using declarations.
Definition: UnusedUsingDeclsCheck.h:25
clang::tidy::misc::StringLiteralWithEmbeddedNulCheck
Find suspicious string literals with embedded NUL characters.
Definition: StringLiteralWithEmbeddedNulCheck.h:23
SuspiciousStringCompareCheck.h
clang::tidy::misc::SuspiciousMissingCommaCheck
This check finds string literals which are probably concatenated accidentally.
Definition: SuspiciousMissingCommaCheck.h:24
MacroParenthesesCheck.h
clang::tidy::misc::SizeofExpressionCheck
Find suspicious usages of sizeof expression.
Definition: SizeofExpressionCheck.h:23
clang::tidy::misc::MacroParenthesesCheck
Finds macros that can have unexpected behaviour due to missing parentheses.
Definition: MacroParenthesesCheck.h:32
SizeofContainerCheck.h
UndelegatedConstructor.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
clang::tidy::misc::NewDeleteOverloadsCheck
Definition: NewDeleteOverloadsCheck.h:21
clang::tidy::misc::NonCopyableObjectsCheck
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
Definition: NonCopyableObjects.h:21
UnusedAliasDeclsCheck.h
MisplacedWideningCastCheck.h
LambdaFunctionNameCheck.h
clang::tidy::misc::LambdaFunctionNameCheck
Detect when func or FUNCTION is being used from within a lambda.
Definition: LambdaFunctionNameCheck.h:25
clang::tidy::X
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
clang::tidy::misc::MisplacedWideningCastCheck
Find casts of calculation results to bigger type.
Definition: MisplacedWideningCastCheck.h:31
clang::tidy::misc::RedundantExpressionCheck
The checker detects expressions that are redundant, because they contain ineffective, useless parts.
Definition: RedundantExpressionCheck.h:24
clang::tidy::misc::StringCompareCheck
This check flags all calls compare when used to check for string equality or inequality.
Definition: StringCompareCheck.h:24
IncorrectRoundings.h
StringCompareCheck.h
UnusedRAIICheck.h
clang::tidy::misc::ForwardingReferenceOverloadCheck
The checker looks for constructors that can act as copy or move constructors through their forwarding...
Definition: ForwardingReferenceOverloadCheck.h:30
clang::tidy::misc::SuspiciousEnumUsageCheck
The checker detects various cases when an enum is probably misused (as a bitmask).
Definition: SuspiciousEnumUsageCheck.h:23
UnusedParametersCheck.h
clang::tidy::MiscModuleAnchorSource
volatile int MiscModuleAnchorSource
Definition: MiscTidyModule.cpp:117
clang::tidy::misc::SizeofContainerCheck
Find usages of sizeof on expressions of STL container types.
Definition: SizeofContainerCheck.h:24
clang::tidy::misc::DefinitionsInHeadersCheck
Finds non-extern non-inline function and variable definitions in header files, which can lead to pote...
Definition: DefinitionsInHeadersCheck.h:34
UniqueptrResetReleaseCheck.h
clang::tidy::misc::UnconventionalAssignOperatorCheck
Finds declarations of assignment operators with the wrong return and/or argument types and definition...
Definition: UnconventionalAssignOperatorCheck.h:30
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::misc::UnusedParametersCheck
Finds unused parameters and fixes them, so that -Wunused-parameter can be turned on.
Definition: UnusedParametersCheck.h:21
SuspiciousSemicolonCheck.h
clang::tidy::misc::SuspiciousSemicolonCheck
This check finds semicolon that modifies the meaning of the program unintendedly. ...
Definition: SuspiciousSemicolonCheck.h:24
DefinitionsInHeadersCheck.h
SuspiciousMissingCommaCheck.h
StringLiteralWithEmbeddedNulCheck.h
UnusedUsingDeclsCheck.h