clang-tools 23.0.0git
HICPPTidyModule.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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"
41#include "SignedBitwiseCheck.h"
42
43namespace clang::tidy {
44namespace hicpp {
45namespace {
46
47class HICPPModule : public ClangTidyModule {
48public:
49 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
51 "hicpp-avoid-c-arrays");
53 "hicpp-avoid-goto");
55 "hicpp-braces-around-statements");
57 "hicpp-deprecated-headers");
59 "hicpp-exception-baseclass");
61 "hicpp-ignored-remove-result");
63 "hicpp-multiway-paths-covered");
64 CheckFactories.registerCheck<SignedBitwiseCheck>("hicpp-signed-bitwise");
66 "hicpp-explicit-conversions");
68 "hicpp-function-size");
70 "hicpp-named-parameter");
72 "hicpp-invalid-access-moved");
74 "hicpp-member-init");
76 "hicpp-move-const-arg");
78 "hicpp-new-delete-operators");
80 "hicpp-noexcept-move");
81 CheckFactories
83 "hicpp-no-array-decay");
85 "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 ClangTidyOptions getModuleOptions() override {
115 ClangTidyOptions Options;
117 Opts["hicpp-ignored-remove-result.CheckedFunctions"] =
118 "^::std::remove$;^::std::remove_if$;^::std::unique$";
119 Opts["hicpp-ignored-remove-result.CheckedReturnTypes"] = "";
120 Opts["hicpp-ignored-remove-result.AllowCastToVoid"] = "true";
121 return Options;
122 }
123};
124
125} // namespace
126
127// Register the HICPPModule using this statically initialized variable.
128static ClangTidyModuleRegistry::Add<HICPPModule>
129 X("hicpp-module", "Adds High-Integrity C++ checks.");
130
131} // namespace hicpp
132
133// This anchor is used to force the linker to link in the generated object file
134// and thus register the HICPPModule.
135volatile int HICPPModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage)
136
137} // namespace clang::tidy
A collection of ClangTidyCheckFactory instances.
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Check for thrown exceptions and enforce they are all derived from std::exception.
Finds creation of temporary objects in constructors that look like a function call to another constru...
Detects function calls where the return value is unused.
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.
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.
Find occasions where not all codepaths are explicitly covered in code.
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,...
static ClangTidyModuleRegistry::Add< HICPPModule > X("hicpp-module", "Adds High-Integrity C++ checks.")
volatile int HICPPModuleAnchorSource
Contains options for clang-tidy.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
llvm::StringMap< ClangTidyValue > OptionMap