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"
17 #include "DanglingHandleCheck.h"
18 #include "FoldInitTypeCheck.h"
20 #include "InaccurateEraseCheck.h"
21 #include "IntegerDivisionCheck.h"
25 #include "StringConstructorCheck.h"
28 #include "UseAfterMoveCheck.h"
29 #include "VirtualNearMissCheck.h"
30 
31 namespace clang {
32 namespace tidy {
33 namespace bugprone {
34 
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");
43  "bugprone-bool-pointer-implicit-conversion");
45  "bugprone-copy-constructor-init");
46  CheckFactories.registerCheck<DanglingHandleCheck>(
47  "bugprone-dangling-handle");
48  CheckFactories.registerCheck<FoldInitTypeCheck>(
49  "bugprone-fold-init-type");
51  "bugprone-forward-declaration-namespace");
52  CheckFactories.registerCheck<InaccurateEraseCheck>(
53  "bugprone-inaccurate-erase");
54  CheckFactories.registerCheck<IntegerDivisionCheck>(
55  "bugprone-integer-division");
57  "bugprone-misplaced-operator-in-strlen-in-alloc");
59  "bugprone-move-forwarding-reference");
61  "bugprone-multiple-statement-macro");
62  CheckFactories.registerCheck<StringConstructorCheck>(
63  "bugprone-string-constructor");
65  "bugprone-suspicious-memset-usage");
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
Checks if an unused forward declaration is in a wrong namespace.
Finds memset calls with potential mistakes in their arguments.
Finds copy constructors where the ctor don&#39;t call the copy constructor of the base class...
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Checks for conditions based on implicit conversion from a bool pointer to bool.
The check warns if an object is used after it has been moved, without an intervening reinitialization...
Finds cases where 1 is added to the string in the argument to a function in the strlen() family inste...
Detect multiple statement macros that are used in unbraced conditionals.
A collection of ClangTidyCheckFactory instances.
Find and flag invalid initializer values in folds, e.g.
Checks for near miss of virtual methods.
The check warns if std::move is applied to a forwarding reference (i.e.
Detect dangling references in value handlers like std::experimental::string_view. ...
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Finds cases where integer division in a floating point context is likely to cause unintended loss of ...
Finds suspicious string constructor and check their parameters.
static ClangTidyModuleRegistry::Add< bugprone::BugproneModule > X("bugprone-module", "Adds checks for bugprone code constructs.")
Checks for inaccurate use of the erase() method.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
volatile int BugproneModuleAnchorSource
Finds calls of memory manipulation functions memset(), memcpy() and memmove() on not TriviallyCopyabl...