clang-tools  8.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/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 "../bugprone/UndelegatedConstructorCheck.h"
25 #include "../modernize/AvoidCArraysCheck.h"
26 #include "../modernize/DeprecatedHeadersCheck.h"
27 #include "../modernize/UseAutoCheck.h"
28 #include "../modernize/UseEmplaceCheck.h"
29 #include "../modernize/UseEqualsDefaultCheck.h"
30 #include "../modernize/UseEqualsDeleteCheck.h"
31 #include "../modernize/UseNoexceptCheck.h"
32 #include "../modernize/UseNullptrCheck.h"
33 #include "../modernize/UseOverrideCheck.h"
34 #include "../performance/MoveConstArgCheck.h"
35 #include "../performance/NoexceptMoveConstructorCheck.h"
36 #include "../readability/BracesAroundStatementsCheck.h"
37 #include "../readability/FunctionSizeCheck.h"
38 #include "../readability/IdentifierNamingCheck.h"
39 #include "../readability/UppercaseLiteralSuffixCheck.h"
42 #include "NoAssemblerCheck.h"
43 #include "SignedBitwiseCheck.h"
44 
45 namespace clang {
46 namespace tidy {
47 namespace hicpp {
48 
49 class HICPPModule : public ClangTidyModule {
50 public:
51  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
53  "hicpp-avoid-c-arrays");
55  "hicpp-avoid-goto");
57  "hicpp-braces-around-statements");
59  "hicpp-deprecated-headers");
60  CheckFactories.registerCheck<ExceptionBaseclassCheck>(
61  "hicpp-exception-baseclass");
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");
84  CheckFactories.registerCheck<NoAssemblerCheck>("hicpp-no-assembler");
86  "hicpp-no-malloc");
87  CheckFactories
89  "hicpp-special-member-functions");
90  CheckFactories.registerCheck<misc::StaticAssertCheck>(
91  "hicpp-static-assert");
92  CheckFactories.registerCheck<modernize::UseAutoCheck>("hicpp-use-auto");
94  "hicpp-undelegated-constructor");
96  "hicpp-use-emplace");
98  "hicpp-use-equals-default");
100  "hicpp-use-equals-delete");
102  "hicpp-use-noexcept");
104  "hicpp-use-nullptr");
106  "hicpp-use-override");
108  "hicpp-uppercase-literal-suffix");
110  "hicpp-vararg");
111  }
112 };
113 
114 // Register the HICPPModule using this statically initialized variable.
115 static ClangTidyModuleRegistry::Add<HICPPModule>
116  X("hicpp-module", "Adds High-Integrity C++ checks.");
117 
118 } // namespace hicpp
119 
120 // This anchor is used to force the linker to link in the generated object file
121 // and thus register the HICPPModule.
122 volatile int HICPPModuleAnchorSource = 0;
123 
124 } // namespace tidy
125 } // namespace clang
Checks for classes where some, but not all, of the special member functions are defined.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
static ClangTidyModuleRegistry::Add< HICPPModule > X("hicpp-module", "Adds High-Integrity C++ checks.")
Replace dynamic exception specifications, with noexcept (or user-defined macro) or noexcept(false)...
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Detects when the integral literal or floating point literal has non-uppercase suffix, and suggests to make the suffix uppercase.
Find assembler statements.
Use C++11&#39;s override and remove virtual where applicable.
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Replaces assert() with static_assert() if the condition is evaluatable at compile time...
The check warns if an object is used after it has been moved, without an intervening reinitialization...
This checker is concerned with C-style memory management and suggest modern alternatives to it...
Definition: NoMallocCheck.h:28
Replace default bodies of special member functions with &#39;= default;&#39;.
A collection of ClangTidyCheckFactory instances.
Check for thrown exceptions and enforce they are all derived from std::exception. ...
The usage of goto for control flow is error prone and should be replaced with looping constructs...
Checks for large functions based on various metrics.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
volatile int HICPPModuleAnchorSource
Find C-style array types and recommend to use std::array<> / std::vector<>.
Find occasions where not all codepaths are explicitly covered in code.
This check replaces deprecated C library headers with their C++ STL alternatives. ...
Finds creation of temporary objects in constructors that look like a function call to another constru...
This check implements the rule 5.6.1 of the HICPP Standard, which disallows bitwise operations on sig...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
This check flags all calls to c-style variadic functions and all use of va_arg.
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
Mark unimplemented private special member functions with &#39;= delete&#39;.
Find casts of calculation results to bigger type.
Checks that all single-argument constructors are explicit.
Checks for identifiers naming style mismatch.
This check looks for cases when inserting new element into std::vector but the element is constructed...