clang-tools  14.0.0git
HICPPTidyModule.cpp
Go to the documentation of this file.
1 //===------- HICPPTidyModule.cpp - clang-tidy -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "../ClangTidy.h"
10 #include "../ClangTidyModule.h"
11 #include "../ClangTidyModuleRegistry.h"
12 #include "../bugprone/UndelegatedConstructorCheck.h"
13 #include "../bugprone/UseAfterMoveCheck.h"
14 #include "../cppcoreguidelines/AvoidGotoCheck.h"
15 #include "../cppcoreguidelines/NoMallocCheck.h"
16 #include "../cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.h"
17 #include "../cppcoreguidelines/ProTypeMemberInitCheck.h"
18 #include "../cppcoreguidelines/ProTypeVarargCheck.h"
19 #include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h"
20 #include "../google/DefaultArgumentsCheck.h"
21 #include "../google/ExplicitConstructorCheck.h"
22 #include "../misc/NewDeleteOverloadsCheck.h"
23 #include "../misc/StaticAssertCheck.h"
24 #include "../modernize/AvoidCArraysCheck.h"
25 #include "../modernize/DeprecatedHeadersCheck.h"
26 #include "../modernize/UseAutoCheck.h"
27 #include "../modernize/UseEmplaceCheck.h"
28 #include "../modernize/UseEqualsDefaultCheck.h"
29 #include "../modernize/UseEqualsDeleteCheck.h"
30 #include "../modernize/UseNoexceptCheck.h"
31 #include "../modernize/UseNullptrCheck.h"
32 #include "../modernize/UseOverrideCheck.h"
33 #include "../performance/MoveConstArgCheck.h"
34 #include "../performance/NoexceptMoveConstructorCheck.h"
35 #include "../readability/BracesAroundStatementsCheck.h"
36 #include "../readability/FunctionSizeCheck.h"
37 #include "../readability/NamedParameterCheck.h"
38 #include "../readability/UppercaseLiteralSuffixCheck.h"
41 #include "NoAssemblerCheck.h"
42 #include "SignedBitwiseCheck.h"
43 
44 namespace clang {
45 namespace tidy {
46 namespace hicpp {
47 
48 class HICPPModule : public ClangTidyModule {
49 public:
50  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
52  "hicpp-avoid-c-arrays");
54  "hicpp-avoid-goto");
56  "hicpp-braces-around-statements");
58  "hicpp-deprecated-headers");
59  CheckFactories.registerCheck<ExceptionBaseclassCheck>(
60  "hicpp-exception-baseclass");
62  "hicpp-multiway-paths-covered");
63  CheckFactories.registerCheck<SignedBitwiseCheck>("hicpp-signed-bitwise");
65  "hicpp-explicit-conversions");
67  "hicpp-function-size");
69  "hicpp-named-parameter");
71  "hicpp-invalid-access-moved");
73  "hicpp-member-init");
75  "hicpp-move-const-arg");
77  "hicpp-new-delete-operators");
79  "hicpp-noexcept-move");
80  CheckFactories
82  "hicpp-no-array-decay");
83  CheckFactories.registerCheck<NoAssemblerCheck>("hicpp-no-assembler");
85  "hicpp-no-malloc");
86  CheckFactories
88  "hicpp-special-member-functions");
89  CheckFactories.registerCheck<misc::StaticAssertCheck>(
90  "hicpp-static-assert");
91  CheckFactories.registerCheck<modernize::UseAutoCheck>("hicpp-use-auto");
93  "hicpp-undelegated-constructor");
95  "hicpp-use-emplace");
97  "hicpp-use-equals-default");
99  "hicpp-use-equals-delete");
101  "hicpp-use-noexcept");
103  "hicpp-use-nullptr");
105  "hicpp-use-override");
107  "hicpp-uppercase-literal-suffix");
109  "hicpp-vararg");
110  }
111 };
112 
113 // Register the HICPPModule using this statically initialized variable.
114 static ClangTidyModuleRegistry::Add<HICPPModule>
115  X("hicpp-module", "Adds High-Integrity C++ checks.");
116 
117 } // namespace hicpp
118 
119 // This anchor is used to force the linker to link in the generated object file
120 // and thus register the HICPPModule.
121 volatile int HICPPModuleAnchorSource = 0;
122 
123 } // namespace tidy
124 } // namespace clang
ExceptionBaseclassCheck.h
clang::tidy::misc::NewDeleteOverloadsCheck
Definition: NewDeleteOverloadsCheck.h:20
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck
Checks for classes where some, but not all, of the special member functions are defined.
Definition: SpecialMemberFunctionsCheck.h:25
MultiwayPathsCoveredCheck.h
clang::tidy::modernize::UseAutoCheck
Definition: UseAutoCheck.h:18
clang::tidy::modernize::UseEmplaceCheck
This check looks for cases when inserting new element into std::vector but the element is constructed...
Definition: UseEmplaceCheck.h:27
clang::tidy::cppcoreguidelines::NoMallocCheck
This checker is concerned with C-style memory management and suggest modern alternatives to it.
Definition: NoMallocCheck.h:25
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:43
clang::tidy::google::ExplicitConstructorCheck
Checks that all single-argument constructors are explicit.
Definition: ExplicitConstructorCheck.h:24
clang::tidy::modernize::UseEqualsDefaultCheck
Replace default bodies of special member functions with '= default;'.
Definition: UseEqualsDefaultCheck.h:37
clang::tidy::cppcoreguidelines::AvoidGotoCheck
The usage of goto for control flow is error prone and should be replaced with looping constructs.
Definition: AvoidGotoCheck.h:23
SignedBitwiseCheck.h
clang::tidy::performance::MoveConstArgCheck
Find casts of calculation results to bigger type.
Definition: MoveConstArgCheck.h:24
clang::tidy::HICPPModuleAnchorSource
volatile int HICPPModuleAnchorSource
Definition: HICPPTidyModule.cpp:121
clang::tidy::hicpp::NoAssemblerCheck
Find assembler statements.
Definition: NoAssemblerCheck.h:22
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:28
clang::tidy::readability::UppercaseLiteralSuffixCheck
Detects when the integral literal or floating point literal has non-uppercase suffix,...
Definition: UppercaseLiteralSuffixCheck.h:25
clang::tidy::hicpp::HICPPModule
Definition: HICPPTidyModule.cpp:48
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:50
clang::tidy::bugprone::UndelegatedConstructorCheck
Finds creation of temporary objects in constructors that look like a function call to another constru...
Definition: UndelegatedConstructorCheck.h:23
clang::tidy::hicpp::X
static ClangTidyModuleRegistry::Add< HICPPModule > X("hicpp-module", "Adds High-Integrity C++ checks.")
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:23
clang::tidy::hicpp::MultiwayPathsCoveredCheck
Find occasions where not all codepaths are explicitly covered in code.
Definition: MultiwayPathsCoveredCheck.h:24
clang::tidy::cppcoreguidelines::ProTypeMemberInitCheck
Implements C++ Core Guidelines Type.6.
Definition: ProTypeMemberInitCheck.h:34
clang::tidy::misc::StaticAssertCheck
Replaces assert() with static_assert() if the condition is evaluatable at compile time.
Definition: StaticAssertCheck.h:25
clang::tidy::cppcoreguidelines::ProBoundsArrayToPointerDecayCheck
This check flags all array to pointer decays.
Definition: ProBoundsArrayToPointerDecayCheck.h:22
clang::tidy::modernize::DeprecatedHeadersCheck
This check replaces deprecated C library headers with their C++ STL alternatives.
Definition: DeprecatedHeadersCheck.h:35
clang::tidy::hicpp::ExceptionBaseclassCheck
Check for thrown exceptions and enforce they are all derived from std::exception.
Definition: ExceptionBaseclassCheck.h:22
clang::tidy::modernize::UseOverrideCheck
Use C++11's override and remove virtual where applicable.
Definition: UseOverrideCheck.h:19
clang::tidy::readability::FunctionSizeCheck
Checks for large functions based on various metrics.
Definition: FunctionSizeCheck.h:37
clang::tidy::performance::NoexceptMoveConstructorCheck
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Definition: NoexceptMoveConstructorCheck.h:25
NoAssemblerCheck.h
clang::tidy::bugprone::UseAfterMoveCheck
The check warns if an object is used after it has been moved, without an intervening reinitialization...
Definition: UseAfterMoveCheck.h:23
clang::tidy::readability::NamedParameterCheck
Find functions with unnamed arguments.
Definition: NamedParameterCheck.h:29
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::modernize::UseNoexceptCheck
Replace dynamic exception specifications, with noexcept (or user-defined macro) or noexcept(false).
Definition: UseNoexceptCheck.h:32
clang::tidy::cppcoreguidelines::ProTypeVarargCheck
This check flags all calls to c-style variadic functions and all use of va_arg.
Definition: ProTypeVarargCheck.h:23
clang::tidy::modernize::UseEqualsDeleteCheck
Mark unimplemented private special member functions with '= delete'.
Definition: UseEqualsDeleteCheck.h:37
clang::tidy::modernize::UseNullptrCheck
Definition: UseNullptrCheck.h:18
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:81
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::modernize::AvoidCArraysCheck
Find C-style array types and recommend to use std::array<> / std::vector<>.
Definition: AvoidCArraysCheck.h:22