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