clang-tools  3.8.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"
18 #include "InaccurateEraseCheck.h"
20 #include "MacroParenthesesCheck.h"
26 #include "NonCopyableObjects.h"
27 #include "SizeofContainerCheck.h"
28 #include "StaticAssertCheck.h"
30 #include "SwappedArgumentsCheck.h"
32 #include "UndelegatedConstructor.h"
34 #include "UnusedAliasDeclsCheck.h"
35 #include "UnusedParametersCheck.h"
36 #include "UnusedRAIICheck.h"
37 #include "VirtualNearMissCheck.h"
38 
39 namespace clang {
40 namespace tidy {
41 namespace misc {
42 
43 class MiscModule : public ClangTidyModule {
44 public:
45  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
46  CheckFactories.registerCheck<ArgumentCommentCheck>("misc-argument-comment");
47  CheckFactories.registerCheck<AssertSideEffectCheck>(
48  "misc-assert-side-effect");
50  "misc-assign-operator-signature");
52  "misc-bool-pointer-implicit-conversion");
54  "misc-definitions-in-headers");
55  CheckFactories.registerCheck<InaccurateEraseCheck>(
56  "misc-inaccurate-erase");
58  "misc-inefficient-algorithm");
59  CheckFactories.registerCheck<MacroParenthesesCheck>(
60  "misc-macro-parentheses");
62  "misc-macro-repeated-side-effects");
64  "misc-move-const-arg");
66  "misc-move-constructor-init");
67  CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
68  "misc-new-delete-overloads");
70  "misc-noexcept-move-constructor");
71  CheckFactories.registerCheck<NonCopyableObjectsCheck>(
72  "misc-non-copyable-objects");
73  CheckFactories.registerCheck<SizeofContainerCheck>("misc-sizeof-container");
74  CheckFactories.registerCheck<StaticAssertCheck>(
75  "misc-static-assert");
77  "misc-string-integer-assignment");
78  CheckFactories.registerCheck<SwappedArgumentsCheck>(
79  "misc-swapped-arguments");
81  "misc-throw-by-value-catch-by-reference");
83  "misc-undelegated-constructor");
85  "misc-uniqueptr-reset-release");
86  CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
87  "misc-unused-alias-decls");
88  CheckFactories.registerCheck<UnusedParametersCheck>(
89  "misc-unused-parameters");
90  CheckFactories.registerCheck<UnusedRAIICheck>("misc-unused-raii");
91  CheckFactories.registerCheck<VirtualNearMissCheck>(
92  "misc-virtual-near-miss");
93  }
94 };
95 
96 } // namespace misc
97 
98 // Register the MiscTidyModule using this statically initialized variable.
99 static ClangTidyModuleRegistry::Add<misc::MiscModule>
100 X("misc-module", "Adds miscellaneous lint checks.");
101 
102 // This anchor is used to force the linker to link in the generated object file
103 // and thus register the MiscModule.
104 volatile int MiscModuleAnchorSource = 0;
105 
106 } // namespace tidy
107 } // namespace clang
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
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.
Finds assert() with side effect.
Finds temporaries that look like RAII objects.
Finds creation of temporary objects in constructors that look like a function call to another constru...
checks for locations that do not throw by value
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Checks for near miss of virtual methods.
Find usages of sizeof on expressions of STL container types.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
The check flags dereferences and non-pointer declarations of objects that are not meant to be passed ...
A collection of ClangTidyCheckFactory instances.
Finds unused parameters and fixes them, so that -Wunused-parameter can be turned on.
Finds declarations of assign operators with the wrong return and/or argument types.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Finds macros that can have unexpected behaviour due to missing parentheses.
Finds instances where an integer is assigned to a string.
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
volatile int MiscModuleAnchorSource
Finds unused namespace alias declarations.
Checks for inaccurate use of the erase() method.
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Warns on inefficient use of STL algorithms on associative containers.