clang-tools  3.9.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 "ArgumentCommentCheck.h"
14 #include "AssertSideEffectCheck.h"
15 #include "MisplacedConstCheck.h"
18 #include "DanglingHandleCheck.h"
20 #include "FoldInitTypeCheck.h"
22 #include "InaccurateEraseCheck.h"
23 #include "IncorrectRoundings.h"
25 #include "MacroParenthesesCheck.h"
33 #include "NonCopyableObjects.h"
36 #include "SizeofContainerCheck.h"
37 #include "SizeofExpressionCheck.h"
38 #include "StaticAssertCheck.h"
39 #include "StringConstructorCheck.h"
45 #include "SwappedArgumentsCheck.h"
47 #include "UndelegatedConstructor.h"
49 #include "UnusedAliasDeclsCheck.h"
50 #include "UnusedParametersCheck.h"
51 #include "UnusedRAIICheck.h"
52 #include "UnusedUsingDeclsCheck.h"
53 #include "VirtualNearMissCheck.h"
54 
55 namespace clang {
56 namespace tidy {
57 namespace misc {
58 
59 class MiscModule : public ClangTidyModule {
60 public:
61  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
62  CheckFactories.registerCheck<ArgumentCommentCheck>("misc-argument-comment");
63  CheckFactories.registerCheck<AssertSideEffectCheck>(
64  "misc-assert-side-effect");
65  CheckFactories.registerCheck<MisplacedConstCheck>(
66  "misc-misplaced-const");
68  "misc-unconventional-assign-operator");
70  "misc-bool-pointer-implicit-conversion");
71  CheckFactories.registerCheck<DanglingHandleCheck>(
72  "misc-dangling-handle");
74  "misc-definitions-in-headers");
75  CheckFactories.registerCheck<FoldInitTypeCheck>(
76  "misc-fold-init-type");
78  "misc-forward-declaration-namespace");
79  CheckFactories.registerCheck<InaccurateEraseCheck>(
80  "misc-inaccurate-erase");
81  CheckFactories.registerCheck<IncorrectRoundings>(
82  "misc-incorrect-roundings");
84  "misc-inefficient-algorithm");
85  CheckFactories.registerCheck<MacroParenthesesCheck>(
86  "misc-macro-parentheses");
88  "misc-macro-repeated-side-effects");
90  "misc-misplaced-widening-cast");
92  "misc-move-const-arg");
94  "misc-move-constructor-init");
96  "misc-multiple-statement-macro");
97  CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
98  "misc-new-delete-overloads");
100  "misc-noexcept-move-constructor");
101  CheckFactories.registerCheck<NonCopyableObjectsCheck>(
102  "misc-non-copyable-objects");
104  "misc-pointer-and-integral-operation");
105  CheckFactories.registerCheck<RedundantExpressionCheck>(
106  "misc-redundant-expression");
107  CheckFactories.registerCheck<SizeofContainerCheck>("misc-sizeof-container");
108  CheckFactories.registerCheck<SizeofExpressionCheck>(
109  "misc-sizeof-expression");
110  CheckFactories.registerCheck<StaticAssertCheck>(
111  "misc-static-assert");
112  CheckFactories.registerCheck<StringConstructorCheck>(
113  "misc-string-constructor");
115  "misc-string-integer-assignment");
117  "misc-string-literal-with-embedded-nul");
119  "misc-suspicious-missing-comma");
120  CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
121  "misc-suspicious-semicolon");
123  "misc-suspicious-string-compare");
124  CheckFactories.registerCheck<SwappedArgumentsCheck>(
125  "misc-swapped-arguments");
127  "misc-throw-by-value-catch-by-reference");
129  "misc-undelegated-constructor");
131  "misc-uniqueptr-reset-release");
132  CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
133  "misc-unused-alias-decls");
134  CheckFactories.registerCheck<UnusedParametersCheck>(
135  "misc-unused-parameters");
136  CheckFactories.registerCheck<UnusedRAIICheck>("misc-unused-raii");
137  CheckFactories.registerCheck<UnusedUsingDeclsCheck>(
138  "misc-unused-using-decls");
139  CheckFactories.registerCheck<VirtualNearMissCheck>(
140  "misc-virtual-near-miss");
141  }
142 };
143 
144 } // namespace misc
145 
146 // Register the MiscTidyModule using this statically initialized variable.
147 static ClangTidyModuleRegistry::Add<misc::MiscModule>
148 X("misc-module", "Adds miscellaneous lint checks.");
149 
150 // This anchor is used to force the linker to link in the generated object file
151 // and thus register the MiscModule.
152 volatile int MiscModuleAnchorSource = 0;
153 
154 } // namespace tidy
155 } // 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.
static ClangTidyModuleRegistry::Add< cert::CERTModule > X("cert-module","Adds lint checks corresponding to CERT secure coding guidelines.")
Finds potentially swapped arguments by looking at implicit conversions.
Find and replace unique_ptr::reset(release()) with std::move().
Checks for conditions based on implicit conversion from a bool pointer to bool.
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 for near miss of virtual methods.
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.
Detect multiple statement macros that are used in unbraced conditionals.
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Finds suspicious string constructor and check their parameters.
Find casts of calculation results to bigger type.
Detect useless or suspicious redundant expressions.
Finds assert() with side effect.
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Detect dangling references in value handlers like std::experimental::string_view. ...
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...
Find suspicious expressions involving pointer and integral types.
Find and flag invalid initializer values in folds, e.g.
Checks if an unused forward declaration is in a wrong namespace.
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. ...
Checks for inaccurate use of the erase() method.
Warns on inefficient use of STL algorithms on associative containers.