clang-tools 20.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"
42#include "NoAssemblerCheck.h"
43#include "SignedBitwiseCheck.h"
44
45namespace clang::tidy {
46namespace hicpp {
47
49public:
50 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
52 "hicpp-avoid-c-arrays");
54 "hicpp-avoid-goto");
56 "hicpp-braces-around-statements");
58 "hicpp-deprecated-headers");
60 "hicpp-exception-baseclass");
62 "hicpp-ignored-remove-result");
64 "hicpp-multiway-paths-covered");
65 CheckFactories.registerCheck<SignedBitwiseCheck>("hicpp-signed-bitwise");
67 "hicpp-explicit-conversions");
69 "hicpp-function-size");
71 "hicpp-named-parameter");
73 "hicpp-invalid-access-moved");
75 "hicpp-member-init");
77 "hicpp-move-const-arg");
79 "hicpp-new-delete-operators");
81 "hicpp-noexcept-move");
82 CheckFactories
84 "hicpp-no-array-decay");
85 CheckFactories.registerCheck<NoAssemblerCheck>("hicpp-no-assembler");
87 "hicpp-no-malloc");
88 CheckFactories
90 "hicpp-special-member-functions");
92 "hicpp-static-assert");
93 CheckFactories.registerCheck<modernize::UseAutoCheck>("hicpp-use-auto");
95 "hicpp-undelegated-constructor");
97 "hicpp-use-emplace");
99 "hicpp-use-equals-default");
101 "hicpp-use-equals-delete");
103 "hicpp-use-noexcept");
105 "hicpp-use-nullptr");
107 "hicpp-use-override");
109 "hicpp-uppercase-literal-suffix");
111 "hicpp-vararg");
112 }
113};
114
115// Register the HICPPModule using this statically initialized variable.
116static ClangTidyModuleRegistry::Add<HICPPModule>
117 X("hicpp-module", "Adds High-Integrity C++ checks.");
118
119} // namespace hicpp
120
121// This anchor is used to force the linker to link in the generated object file
122// and thus register the HICPPModule.
123volatile int HICPPModuleAnchorSource = 0;
124
125} // namespace clang::tidy
int X
A collection of ClangTidyCheckFactory instances.
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Finds creation of temporary objects in constructors that look like a function call to another constru...
The check warns if an object is used after it has been moved, without an intervening reinitialization...
The usage of goto for control flow is error prone and should be replaced with looping constructs.
This checker is concerned with C-style memory management and suggest modern alternatives to it.
Definition: NoMallocCheck.h:23
This check flags all calls to c-style variadic functions and all use of va_arg.
Checks for classes where some, but not all, of the special member functions are defined.
Checks that all single-argument constructors are explicit.
Check for thrown exceptions and enforce they are all derived from std::exception.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
Ensure that the result of std::remove, std::remove_if and std::unique are not ignored according to ru...
Find occasions where not all codepaths are explicitly covered in code.
Find assembler statements.
This check implements the rule 5.6.1 of the HICPP Standard, which disallows bitwise operations on sig...
Replaces assert() with static_assert() if the condition is evaluatable at compile time.
Find C-style array types and recommend to use std::array<> / std::vector<>.
This check replaces deprecated C library headers with their C++ STL alternatives.
This check looks for cases when inserting new element into std::vector but the element is constructed...
Replace default bodies of special member functions with '= default;'.
Identifies unimplemented private special member functions, and recommends using = delete for them.
Replace dynamic exception specifications, with noexcept (or user-defined macro) or noexcept(false).
Use C++11's override and remove virtual where applicable.
Find casts of calculation results to bigger type.
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
Checks for large functions based on various metrics.
Find functions with unnamed arguments.
Detects when the integral literal or floating point literal has non-uppercase suffix,...
volatile int HICPPModuleAnchorSource