clang-tools 6.0.0

BugproneTidyModule.cpp
Go to the documentation of this file.
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
ArgumentCommentCheck.h
clang::tidy::bugprone::ForwardDeclarationNamespaceCheck
Checks if an unused forward declaration is in a wrong namespace.
Definition: ForwardDeclarationNamespaceCheck.h:41
clang::tidy::bugprone::AssertSideEffectCheck
Finds assert() with side effect.
Definition: AssertSideEffectCheck.h:35
clang::tidy::bugprone::SuspiciousMemsetUsageCheck
Finds memset calls with potential mistakes in their arguments.
Definition: SuspiciousMemsetUsageCheck.h:23
clang::tidy::bugprone::CopyConstructorInitCheck
Finds copy constructors where the ctor don&#39;t call the copy constructor of the base class...
Definition: CopyConstructorInitCheck.h:24
InaccurateEraseCheck.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::bugprone::BoolPointerImplicitConversionCheck
Checks for conditions based on implicit conversion from a bool pointer to bool.
Definition: BoolPointerImplicitConversionCheck.h:30
clang::tidy::bugprone::UseAfterMoveCheck
The check warns if an object is used after it has been moved, without an intervening reinitialization...
Definition: UseAfterMoveCheck.h:24
clang::tidy::bugprone::ArgumentCommentCheck
Definition: ArgumentCommentCheck.h:34
clang::tidy::bugprone::MisplacedOperatorInStrlenInAllocCheck
Finds cases where 1 is added to the string in the argument to a function in the strlen() family inste...
Definition: MisplacedOperatorInStrlenInAllocCheck.h:25
clang::tidy::bugprone::MultipleStatementMacroCheck
Detect multiple statement macros that are used in unbraced conditionals.
Definition: MultipleStatementMacroCheck.h:25
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::bugprone::FoldInitTypeCheck
Find and flag invalid initializer values in folds, e.g.
Definition: FoldInitTypeCheck.h:28
BoolPointerImplicitConversionCheck.h
clang::tidy::bugprone::VirtualNearMissCheck
Checks for near miss of virtual methods.
Definition: VirtualNearMissCheck.h:27
clang::tidy::bugprone::MoveForwardingReferenceCheck
The check warns if std::move is applied to a forwarding reference (i.e.
Definition: MoveForwardingReferenceCheck.h:37
MisplacedOperatorInStrlenInAllocCheck.h
CopyConstructorInitCheck.h
MultipleStatementMacroCheck.h
clang::tidy::bugprone::BugproneModule
Definition: BugproneTidyModule.cpp:35
UndefinedMemoryManipulationCheck.h
clang::tidy::bugprone::DanglingHandleCheck
Detect dangling references in value handlers like std::experimental::string_view. ...
Definition: DanglingHandleCheck.h:24
VirtualNearMissCheck.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
clang::tidy::bugprone::IntegerDivisionCheck
Finds cases where integer division in a floating point context is likely to cause unintended loss of ...
Definition: IntegerDivisionCheck.h:24
StringConstructorCheck.h
clang::tidy::bugprone::StringConstructorCheck
Finds suspicious string constructor and check their parameters.
Definition: StringConstructorCheck.h:23
clang::tidy::X
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
DanglingHandleCheck.h
AssertSideEffectCheck.h
clang::tidy::bugprone::InaccurateEraseCheck
Checks for inaccurate use of the erase() method.
Definition: InaccurateEraseCheck.h:26
clang::tidy::bugprone::BugproneModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: BugproneTidyModule.cpp:37
clang::tidy::BugproneModuleAnchorSource
volatile int BugproneModuleAnchorSource
Definition: BugproneTidyModule.cpp:83
clang
Definition: AndroidTidyModule.cpp:28
IntegerDivisionCheck.h
UseAfterMoveCheck.h
ForwardDeclarationNamespaceCheck.h
SuspiciousMemsetUsageCheck.h
FoldInitTypeCheck.h
clang::tidy::bugprone::UndefinedMemoryManipulationCheck
Finds calls of memory manipulation functions memset(), memcpy() and memmove() on not TriviallyCopyabl...
Definition: UndefinedMemoryManipulationCheck.h:25
MoveForwardingReferenceCheck.h