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 "ArgumentCommentCheck.h"
14 #include "AssertSideEffectCheck.h"
15 #include "BoolPointerImplicitConversionCheck.h"
16 #include "CopyConstructorInitCheck.h"
17 #include "DanglingHandleCheck.h"
18 #include "FoldInitTypeCheck.h"
19 #include "ForwardDeclarationNamespaceCheck.h"
20 #include "InaccurateEraseCheck.h"
21 #include "IntegerDivisionCheck.h"
22 #include "MisplacedOperatorInStrlenInAllocCheck.h"
23 #include "MoveForwardingReferenceCheck.h"
24 #include "MultipleStatementMacroCheck.h"
25 #include "StringConstructorCheck.h"
26 #include "SuspiciousMemsetUsageCheck.h"
27 #include "UndefinedMemoryManipulationCheck.h"
28 #include "UseAfterMoveCheck.h"
29 #include "VirtualNearMissCheck.h"
30 
31 namespace clang {
32 namespace tidy {
33 namespace bugprone {
34 
35 class BugproneModule : public ClangTidyModule {
36 public:
37   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38     CheckFactories.registerCheck<ArgumentCommentCheck>(
39         "bugprone-argument-comment");
40     CheckFactories.registerCheck<AssertSideEffectCheck>(
41         "bugprone-assert-side-effect");
42     CheckFactories.registerCheck<BoolPointerImplicitConversionCheck>(
43         "bugprone-bool-pointer-implicit-conversion");
44     CheckFactories.registerCheck<CopyConstructorInitCheck>(
45         "bugprone-copy-constructor-init");
46     CheckFactories.registerCheck<DanglingHandleCheck>(
47         "bugprone-dangling-handle");
48     CheckFactories.registerCheck<FoldInitTypeCheck>(
49         "bugprone-fold-init-type");
50     CheckFactories.registerCheck<ForwardDeclarationNamespaceCheck>(
51         "bugprone-forward-declaration-namespace");
52     CheckFactories.registerCheck<InaccurateEraseCheck>(
53         "bugprone-inaccurate-erase");
54     CheckFactories.registerCheck<IntegerDivisionCheck>(
55         "bugprone-integer-division");
56     CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>(
57         "bugprone-misplaced-operator-in-strlen-in-alloc");
58     CheckFactories.registerCheck<MoveForwardingReferenceCheck>(
59         "bugprone-move-forwarding-reference");
60     CheckFactories.registerCheck<MultipleStatementMacroCheck>(
61         "bugprone-multiple-statement-macro");
62     CheckFactories.registerCheck<StringConstructorCheck>(
63         "bugprone-string-constructor");
64     CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>(
65         "bugprone-suspicious-memset-usage");
66     CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>(
67         "bugprone-undefined-memory-manipulation");
68     CheckFactories.registerCheck<UseAfterMoveCheck>(
69         "bugprone-use-after-move");
70     CheckFactories.registerCheck<VirtualNearMissCheck>(
71         "bugprone-virtual-near-miss");
72   }
73 };
74 
75 } // namespace bugprone
76 
77 // Register the BugproneTidyModule using this statically initialized variable.
78 static ClangTidyModuleRegistry::Add<bugprone::BugproneModule>
79     X("bugprone-module", "Adds checks for bugprone code constructs.");
80 
81 // This anchor is used to force the linker to link in the generated object file
82 // and thus register the BugproneModule.
83 volatile int BugproneModuleAnchorSource = 0;
84 
85 } // namespace tidy
86 } // namespace clang
87