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 "BoolPointerImplicitConversionCheck.h"
16 #include "DanglingHandleCheck.h"
17 #include "DefinitionsInHeadersCheck.h"
18 #include "FoldInitTypeCheck.h"
19 #include "ForwardDeclarationNamespaceCheck.h"
20 #include "InaccurateEraseCheck.h"
21 #include "IncorrectRoundings.h"
22 #include "InefficientAlgorithmCheck.h"
23 #include "MacroParenthesesCheck.h"
24 #include "MacroRepeatedSideEffectsCheck.h"
25 #include "MisplacedConstCheck.h"
26 #include "MisplacedWideningCastCheck.h"
27 #include "MoveConstantArgumentCheck.h"
28 #include "MoveConstructorInitCheck.h"
29 #include "MoveForwardingReferenceCheck.h"
30 #include "MultipleStatementMacroCheck.h"
31 #include "NewDeleteOverloadsCheck.h"
32 #include "NoexceptMoveConstructorCheck.h"
33 #include "NonCopyableObjects.h"
34 #include "RedundantExpressionCheck.h"
35 #include "SizeofContainerCheck.h"
36 #include "SizeofExpressionCheck.h"
37 #include "StaticAssertCheck.h"
38 #include "StringConstructorCheck.h"
39 #include "StringIntegerAssignmentCheck.h"
40 #include "StringLiteralWithEmbeddedNulCheck.h"
41 #include "SuspiciousMissingCommaCheck.h"
42 #include "SuspiciousSemicolonCheck.h"
43 #include "SuspiciousStringCompareCheck.h"
44 #include "SwappedArgumentsCheck.h"
45 #include "ThrowByValueCatchByReferenceCheck.h"
46 #include "UnconventionalAssignOperatorCheck.h"
47 #include "UndelegatedConstructor.h"
48 #include "UniqueptrResetReleaseCheck.h"
49 #include "UnusedAliasDeclsCheck.h"
50 #include "UnusedParametersCheck.h"
51 #include "UnusedRAIICheck.h"
52 #include "UnusedUsingDeclsCheck.h"
53 #include "UseAfterMoveCheck.h"
54 #include "VirtualNearMissCheck.h"
55 
56 namespace clang {
57 namespace tidy {
58 namespace misc {
59 
60 class MiscModule : public ClangTidyModule {
61 public:
62   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
63     CheckFactories.registerCheck<ArgumentCommentCheck>("misc-argument-comment");
64     CheckFactories.registerCheck<AssertSideEffectCheck>(
65         "misc-assert-side-effect");
66     CheckFactories.registerCheck<MisplacedConstCheck>("misc-misplaced-const");
67     CheckFactories.registerCheck<UnconventionalAssignOperatorCheck>(
68         "misc-unconventional-assign-operator");
69     CheckFactories.registerCheck<BoolPointerImplicitConversionCheck>(
70         "misc-bool-pointer-implicit-conversion");
71     CheckFactories.registerCheck<DanglingHandleCheck>("misc-dangling-handle");
72     CheckFactories.registerCheck<DefinitionsInHeadersCheck>(
73         "misc-definitions-in-headers");
74     CheckFactories.registerCheck<FoldInitTypeCheck>("misc-fold-init-type");
75     CheckFactories.registerCheck<ForwardDeclarationNamespaceCheck>(
76         "misc-forward-declaration-namespace");
77     CheckFactories.registerCheck<InaccurateEraseCheck>("misc-inaccurate-erase");
78     CheckFactories.registerCheck<IncorrectRoundings>(
79         "misc-incorrect-roundings");
80     CheckFactories.registerCheck<InefficientAlgorithmCheck>(
81         "misc-inefficient-algorithm");
82     CheckFactories.registerCheck<MacroParenthesesCheck>(
83         "misc-macro-parentheses");
84     CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>(
85         "misc-macro-repeated-side-effects");
86     CheckFactories.registerCheck<MisplacedWideningCastCheck>(
87         "misc-misplaced-widening-cast");
88     CheckFactories.registerCheck<MoveConstantArgumentCheck>(
89         "misc-move-const-arg");
90     CheckFactories.registerCheck<MoveConstructorInitCheck>(
91         "misc-move-constructor-init");
92     CheckFactories.registerCheck<MoveForwardingReferenceCheck>(
93         "misc-move-forwarding-reference");
94     CheckFactories.registerCheck<MultipleStatementMacroCheck>(
95         "misc-multiple-statement-macro");
96     CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
97         "misc-new-delete-overloads");
98     CheckFactories.registerCheck<NoexceptMoveConstructorCheck>(
99         "misc-noexcept-move-constructor");
100     CheckFactories.registerCheck<NonCopyableObjectsCheck>(
101         "misc-non-copyable-objects");
102     CheckFactories.registerCheck<RedundantExpressionCheck>(
103         "misc-redundant-expression");
104     CheckFactories.registerCheck<SizeofContainerCheck>("misc-sizeof-container");
105     CheckFactories.registerCheck<SizeofExpressionCheck>(
106         "misc-sizeof-expression");
107     CheckFactories.registerCheck<StaticAssertCheck>("misc-static-assert");
108     CheckFactories.registerCheck<StringConstructorCheck>(
109         "misc-string-constructor");
110     CheckFactories.registerCheck<StringIntegerAssignmentCheck>(
111         "misc-string-integer-assignment");
112     CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>(
113         "misc-string-literal-with-embedded-nul");
114     CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(
115         "misc-suspicious-missing-comma");
116     CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
117         "misc-suspicious-semicolon");
118     CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
119         "misc-suspicious-string-compare");
120     CheckFactories.registerCheck<SwappedArgumentsCheck>(
121         "misc-swapped-arguments");
122     CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
123         "misc-throw-by-value-catch-by-reference");
124     CheckFactories.registerCheck<UndelegatedConstructorCheck>(
125         "misc-undelegated-constructor");
126     CheckFactories.registerCheck<UniqueptrResetReleaseCheck>(
127         "misc-uniqueptr-reset-release");
128     CheckFactories.registerCheck<UnusedAliasDeclsCheck>(
129         "misc-unused-alias-decls");
130     CheckFactories.registerCheck<UnusedParametersCheck>(
131         "misc-unused-parameters");
132     CheckFactories.registerCheck<UnusedRAIICheck>("misc-unused-raii");
133     CheckFactories.registerCheck<UnusedUsingDeclsCheck>(
134         "misc-unused-using-decls");
135     CheckFactories.registerCheck<UseAfterMoveCheck>("misc-use-after-move");
136     CheckFactories.registerCheck<VirtualNearMissCheck>(
137         "misc-virtual-near-miss");
138   }
139 };
140 
141 } // namespace misc
142 
143 // Register the MiscTidyModule using this statically initialized variable.
144 static ClangTidyModuleRegistry::Add<misc::MiscModule>
145     X("misc-module", "Adds miscellaneous lint checks.");
146 
147 // This anchor is used to force the linker to link in the generated object file
148 // and thus register the MiscModule.
149 volatile int MiscModuleAnchorSource = 0;
150 
151 } // namespace tidy
152 } // namespace clang
153