clang-tools 6.0.0

HICPPTidyModule.cpp
Go to the documentation of this file.
1 //===------- HICPPTidyModule.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 "../bugprone/UseAfterMoveCheck.h"
14 #include "../cppcoreguidelines/NoMallocCheck.h"
15 #include "../cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h"
16 #include "../cppcoreguidelines/ProTypeMemberInitCheck.h"
17 #include "../cppcoreguidelines/ProTypeVarargCheck.h"
18 #include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h"
19 #include "../google/DefaultArgumentsCheck.h"
20 #include "../google/ExplicitConstructorCheck.h"
21 #include "../misc/NewDeleteOverloadsCheck.h"
22 #include "../misc/StaticAssertCheck.h"
23 #include "../misc/UndelegatedConstructor.h"
24 #include "../modernize/DeprecatedHeadersCheck.h"
25 #include "../modernize/UseAutoCheck.h"
26 #include "../modernize/UseEmplaceCheck.h"
27 #include "../modernize/UseEqualsDefaultCheck.h"
28 #include "../modernize/UseEqualsDeleteCheck.h"
29 #include "../modernize/UseNoexceptCheck.h"
30 #include "../modernize/UseNullptrCheck.h"
31 #include "../modernize/UseOverrideCheck.h"
32 #include "../performance/MoveConstArgCheck.h"
33 #include "../performance/NoexceptMoveConstructorCheck.h"
34 #include "../readability/BracesAroundStatementsCheck.h"
35 #include "../readability/FunctionSizeCheck.h"
36 #include "../readability/IdentifierNamingCheck.h"
37 #include "ExceptionBaseclassCheck.h"
38 #include "NoAssemblerCheck.h"
39 #include "SignedBitwiseCheck.h"
40
41 namespace clang {
42 namespace tidy {
43 namespace hicpp {
44
45 class HICPPModule : public ClangTidyModule {
46 public:
47 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
48 CheckFactories.registerCheck<readability::BracesAroundStatementsCheck>(
49 "hicpp-braces-around-statements");
50 CheckFactories.registerCheck<modernize::DeprecatedHeadersCheck>(
51 "hicpp-deprecated-headers");
52 CheckFactories.registerCheck<ExceptionBaseclassCheck>(
53 "hicpp-exception-baseclass");
54 CheckFactories.registerCheck<SignedBitwiseCheck>(
55 "hicpp-signed-bitwise");
56 CheckFactories.registerCheck<google::ExplicitConstructorCheck>(
57 "hicpp-explicit-conversions");
58 CheckFactories.registerCheck<readability::FunctionSizeCheck>(
59 "hicpp-function-size");
60 CheckFactories.registerCheck<readability::IdentifierNamingCheck>(
61 "hicpp-named-parameter");
62 CheckFactories.registerCheck<bugprone::UseAfterMoveCheck>(
63 "hicpp-invalid-access-moved");
64 CheckFactories.registerCheck<cppcoreguidelines::ProTypeMemberInitCheck>(
65 "hicpp-member-init");
66 CheckFactories.registerCheck<performance::MoveConstArgCheck>(
67 "hicpp-move-const-arg");
68 CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
69 "hicpp-new-delete-operators");
70 CheckFactories.registerCheck<performance::NoexceptMoveConstructorCheck>(
71 "hicpp-noexcept-move");
72 CheckFactories
73 .registerCheck<cppcoreguidelines::ProBoundsArrayToPointerDecayCheck>(
74 "hicpp-no-array-decay");
75 CheckFactories.registerCheck<NoAssemblerCheck>("hicpp-no-assembler");
76 CheckFactories.registerCheck<cppcoreguidelines::NoMallocCheck>(
77 "hicpp-no-malloc");
78 CheckFactories
79 .registerCheck<cppcoreguidelines::SpecialMemberFunctionsCheck>(
80 "hicpp-special-member-functions");
81 CheckFactories.registerCheck<misc::StaticAssertCheck>(
82 "hicpp-static-assert");
83 CheckFactories.registerCheck<modernize::UseAutoCheck>("hicpp-use-auto");
84 CheckFactories.registerCheck<misc::UndelegatedConstructorCheck>(
85 "hicpp-undelegated-constructor");
86 CheckFactories.registerCheck<modernize::UseEmplaceCheck>(
87 "hicpp-use-emplace");
88 CheckFactories.registerCheck<modernize::UseEqualsDefaultCheck>(
89 "hicpp-use-equals-default");
90 CheckFactories.registerCheck<modernize::UseEqualsDeleteCheck>(
91 "hicpp-use-equals-delete");
92 CheckFactories.registerCheck<modernize::UseNoexceptCheck>(
93 "hicpp-use-noexcept");
94 CheckFactories.registerCheck<modernize::UseNullptrCheck>(
95 "hicpp-use-nullptr");
96 CheckFactories.registerCheck<modernize::UseOverrideCheck>(
97 "hicpp-use-override");
98 CheckFactories.registerCheck<cppcoreguidelines::ProTypeVarargCheck>(
99 "hicpp-vararg");
100 }
101 };
102
103 // Register the HICPPModule using this statically initialized variable.
104 static ClangTidyModuleRegistry::Add<HICPPModule>
105 X("hicpp-module", "Adds High-Integrity C++ checks.");
106
107 } // namespace hicpp
108
109 // This anchor is used to force the linker to link in the generated object file
110 // and thus register the HICPPModule.
111 volatile int HICPPModuleAnchorSource = 0;
112
113 } // namespace tidy
114 } // namespace clang
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck
Checks for classes where some, but not all, of the special member functions are defined.
Definition: SpecialMemberFunctionsCheck.h:26
clang::tidy::hicpp::HICPPModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: HICPPTidyModule.cpp:47
clang::tidy::hicpp::X
static ClangTidyModuleRegistry::Add< HICPPModule > X("hicpp-module", "Adds High-Integrity C++ checks.")
NoAssemblerCheck.h
clang::tidy::modernize::UseNoexceptCheck
Replace dynamic exception specifications, with noexcept (or user-defined macro) or noexcept(false)...
Definition: UseNoexceptCheck.h:33
clang::tidy::performance::NoexceptMoveConstructorCheck
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Definition: NoexceptMoveConstructorCheck.h:26
clang::tidy::hicpp::NoAssemblerCheck
Find assembler statements.
Definition: NoAssemblerCheck.h:23
clang::tidy::modernize::UseOverrideCheck
Use C++11&#39;s override and remove virtual where applicable.
Definition: UseOverrideCheck.h:20
clang::tidy::misc::UndelegatedConstructorCheck
Finds creation of temporary objects in constructors that look like a function call to another constru...
Definition: UndelegatedConstructor.h:24
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::misc::StaticAssertCheck
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
Definition: StaticAssertCheck.h:26
clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck
Implements C++ Core Guidelines Type.6.
Definition: ProTypeMemberInitCheck.h:34
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::cppcoreguidelines::NoMallocCheck
This checker is concerned with C-style memory management and suggest modern alternatives to it...
Definition: NoMallocCheck.h:28
clang::tidy::modernize::UseEqualsDefaultCheck
Replace default bodies of special member functions with &#39;= default;&#39;.
Definition: UseEqualsDefaultCheck.h:38
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
clang::tidy::hicpp::ExceptionBaseclassCheck
Check for thrown exceptions and enforce they are all derived from std::exception. ...
Definition: ExceptionBaseclassCheck.h:23
SignedBitwiseCheck.h
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition: FunctionSizeCheck.h:36
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
clang::tidy::misc::NewDeleteOverloadsCheck
Definition: NewDeleteOverloadsCheck.h:21
clang::tidy::hicpp::HICPPModule
Definition: HICPPTidyModule.cpp:45
clang::tidy::HICPPModuleAnchorSource
volatile int HICPPModuleAnchorSource
Definition: HICPPTidyModule.cpp:111
clang::tidy::modernize::DeprecatedHeadersCheck
This check replaces deprecated C library headers with their C++ STL alternatives. ...
Definition: DeprecatedHeadersCheck.h:36
clang::tidy::modernize::UseAutoCheck
Definition: UseAutoCheck.h:19
clang::tidy::hicpp::SignedBitwiseCheck
This check implements the rule 5.6.1 of the HICPP Standard, which disallows bitwise operations on sig...
Definition: SignedBitwiseCheck.h:24
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::cppcoreguidelines::ProBoundsArrayToPointerDecayCheck
This check flags all array to pointer decays.
Definition: ProBoundsArrayToPointerDecayCheck.h:23
clang::tidy::cppcoreguidelines::ProTypeVarargCheck
This check flags all calls to c-style variadic functions and all use of va_arg.
Definition: ProTypeVarargCheck.h:24
clang::tidy::readability::BracesAroundStatementsCheck
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
Definition: BracesAroundStatementsCheck.h:44
clang::tidy::modernize::UseEqualsDeleteCheck
Mark unimplemented private special member functions with &#39;= delete&#39;.
Definition: UseEqualsDeleteCheck.h:38
clang::tidy::performance::MoveConstArgCheck
Find casts of calculation results to bigger type.
Definition: MoveConstArgCheck.h:25
clang::tidy::google::ExplicitConstructorCheck
Checks that all single-argument constructors are explicit.
Definition: ExplicitConstructorCheck.h:22
ExceptionBaseclassCheck.h
clang::tidy::readability::IdentifierNamingCheck
Checks for identifiers naming style mismatch.
Definition: IdentifierNamingCheck.h:35
clang::tidy::modernize::UseNullptrCheck
Definition: UseNullptrCheck.h:19
clang::tidy::modernize::UseEmplaceCheck
This check looks for cases when inserting new element into std::vector but the element is constructed...
Definition: UseEmplaceCheck.h:28