1 //===--- BugproneTidyModule.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 "../cppcoreguidelines/NarrowingConversionsCheck.h"
14 #include "ArgumentCommentCheck.h"
15 #include "AssertSideEffectCheck.h"
16 #include "BoolPointerImplicitConversionCheck.h"
17 #include "CopyConstructorInitCheck.h"
18 #include "DanglingHandleCheck.h"
19 #include "ExceptionEscapeCheck.h"
20 #include "FoldInitTypeCheck.h"
21 #include "ForwardDeclarationNamespaceCheck.h"
22 #include "ForwardingReferenceOverloadCheck.h"
23 #include "InaccurateEraseCheck.h"
24 #include "IncorrectRoundingsCheck.h"
25 #include "IntegerDivisionCheck.h"
26 #include "LambdaFunctionNameCheck.h"
27 #include "MacroParenthesesCheck.h"
28 #include "MacroRepeatedSideEffectsCheck.h"
29 #include "MisplacedOperatorInStrlenInAllocCheck.h"
30 #include "MisplacedWideningCastCheck.h"
31 #include "MoveForwardingReferenceCheck.h"
32 #include "MultipleStatementMacroCheck.h"
33 #include "ParentVirtualCallCheck.h"
34 #include "SizeofContainerCheck.h"
35 #include "SizeofExpressionCheck.h"
36 #include "StringConstructorCheck.h"
37 #include "StringIntegerAssignmentCheck.h"
38 #include "StringLiteralWithEmbeddedNulCheck.h"
39 #include "SuspiciousEnumUsageCheck.h"
40 #include "SuspiciousMemsetUsageCheck.h"
41 #include "SuspiciousMissingCommaCheck.h"
42 #include "SuspiciousSemicolonCheck.h"
43 #include "SuspiciousStringCompareCheck.h"
44 #include "SwappedArgumentsCheck.h"
45 #include "TerminatingContinueCheck.h"
46 #include "ThrowKeywordMissingCheck.h"
47 #include "UndefinedMemoryManipulationCheck.h"
48 #include "UndelegatedConstructorCheck.h"
49 #include "UnusedRaiiCheck.h"
50 #include "UnusedReturnValueCheck.h"
51 #include "UseAfterMoveCheck.h"
52 #include "VirtualNearMissCheck.h"
53 
54 namespace clang {
55 namespace tidy {
56 namespace bugprone {
57 
58 class BugproneModule : public ClangTidyModule {
59 public:
60   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
61     CheckFactories.registerCheck<ArgumentCommentCheck>(
62         "bugprone-argument-comment");
63     CheckFactories.registerCheck<AssertSideEffectCheck>(
64         "bugprone-assert-side-effect");
65     CheckFactories.registerCheck<BoolPointerImplicitConversionCheck>(
66         "bugprone-bool-pointer-implicit-conversion");
67     CheckFactories.registerCheck<CopyConstructorInitCheck>(
68         "bugprone-copy-constructor-init");
69     CheckFactories.registerCheck<DanglingHandleCheck>(
70         "bugprone-dangling-handle");
71     CheckFactories.registerCheck<ExceptionEscapeCheck>(
72         "bugprone-exception-escape");
73     CheckFactories.registerCheck<FoldInitTypeCheck>(
74         "bugprone-fold-init-type");
75     CheckFactories.registerCheck<ForwardDeclarationNamespaceCheck>(
76         "bugprone-forward-declaration-namespace");
77     CheckFactories.registerCheck<ForwardingReferenceOverloadCheck>(
78         "bugprone-forwarding-reference-overload");
79     CheckFactories.registerCheck<InaccurateEraseCheck>(
80         "bugprone-inaccurate-erase");
81     CheckFactories.registerCheck<IncorrectRoundingsCheck>(
82         "bugprone-incorrect-roundings");
83     CheckFactories.registerCheck<IntegerDivisionCheck>(
84         "bugprone-integer-division");
85     CheckFactories.registerCheck<LambdaFunctionNameCheck>(
86         "bugprone-lambda-function-name");
87     CheckFactories.registerCheck<MacroParenthesesCheck>(
88         "bugprone-macro-parentheses");
89     CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>(
90         "bugprone-macro-repeated-side-effects");
91     CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>(
92         "bugprone-misplaced-operator-in-strlen-in-alloc");
93     CheckFactories.registerCheck<MisplacedWideningCastCheck>(
94         "bugprone-misplaced-widening-cast");
95     CheckFactories.registerCheck<MoveForwardingReferenceCheck>(
96         "bugprone-move-forwarding-reference");
97     CheckFactories.registerCheck<MultipleStatementMacroCheck>(
98         "bugprone-multiple-statement-macro");
99     CheckFactories.registerCheck<cppcoreguidelines::NarrowingConversionsCheck>(
100         "bugprone-narrowing-conversions");
101     CheckFactories.registerCheck<ParentVirtualCallCheck>(
102         "bugprone-parent-virtual-call");
103     CheckFactories.registerCheck<SizeofContainerCheck>(
104         "bugprone-sizeof-container");
105     CheckFactories.registerCheck<SizeofExpressionCheck>(
106         "bugprone-sizeof-expression");
107     CheckFactories.registerCheck<StringConstructorCheck>(
108         "bugprone-string-constructor");
109     CheckFactories.registerCheck<StringIntegerAssignmentCheck>(
110         "bugprone-string-integer-assignment");
111     CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>(
112         "bugprone-string-literal-with-embedded-nul");
113     CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
114         "bugprone-suspicious-enum-usage");
115     CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>(
116         "bugprone-suspicious-memset-usage");
117     CheckFactories.registerCheck<SuspiciousMissingCommaCheck>(
118         "bugprone-suspicious-missing-comma");
119     CheckFactories.registerCheck<SuspiciousSemicolonCheck>(
120         "bugprone-suspicious-semicolon");
121     CheckFactories.registerCheck<SuspiciousStringCompareCheck>(
122         "bugprone-suspicious-string-compare");
123     CheckFactories.registerCheck<SwappedArgumentsCheck>(
124         "bugprone-swapped-arguments");
125     CheckFactories.registerCheck<TerminatingContinueCheck>(
126         "bugprone-terminating-continue");
127     CheckFactories.registerCheck<ThrowKeywordMissingCheck>(
128         "bugprone-throw-keyword-missing");
129     CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>(
130         "bugprone-undefined-memory-manipulation");
131     CheckFactories.registerCheck<UndelegatedConstructorCheck>(
132         "bugprone-undelegated-constructor");
133     CheckFactories.registerCheck<UnusedRaiiCheck>(
134         "bugprone-unused-raii");
135     CheckFactories.registerCheck<UnusedReturnValueCheck>(
136         "bugprone-unused-return-value");
137     CheckFactories.registerCheck<UseAfterMoveCheck>(
138         "bugprone-use-after-move");
139     CheckFactories.registerCheck<VirtualNearMissCheck>(
140         "bugprone-virtual-near-miss");
141   }
142 };
143 
144 } // namespace bugprone
145 
146 // Register the BugproneTidyModule using this statically initialized variable.
147 static ClangTidyModuleRegistry::Add<bugprone::BugproneModule>
148     X("bugprone-module", "Adds checks for bugprone code constructs.");
149 
150 // This anchor is used to force the linker to link in the generated object file
151 // and thus register the BugproneModule.
152 volatile int BugproneModuleAnchorSource = 0;
153 
154 } // namespace tidy
155 } // namespace clang
156