[Clang] replace 'bitfield' with 'bit-field' for consistency (#117881)
[llvm-project.git] / clang-tools-extra / clang-tidy / cppcoreguidelines / CppCoreGuidelinesTidyModule.cpp
blobe9f0201615616f7359e73e63e6f447728e94a4ab
1 //===-- CppCoreGuidelinesTidyModule.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 //===----------------------------------------------------------------------===//
9 #include "../ClangTidy.h"
10 #include "../ClangTidyModule.h"
11 #include "../ClangTidyModuleRegistry.h"
12 #include "../misc/NonPrivateMemberVariablesInClassesCheck.h"
13 #include "../misc/UnconventionalAssignOperatorCheck.h"
14 #include "../modernize/AvoidCArraysCheck.h"
15 #include "../modernize/MacroToEnumCheck.h"
16 #include "../modernize/UseDefaultMemberInitCheck.h"
17 #include "../modernize/UseOverrideCheck.h"
18 #include "../performance/NoexceptDestructorCheck.h"
19 #include "../performance/NoexceptMoveConstructorCheck.h"
20 #include "../performance/NoexceptSwapCheck.h"
21 #include "../readability/MagicNumbersCheck.h"
22 #include "AvoidCapturingLambdaCoroutinesCheck.h"
23 #include "AvoidConstOrRefDataMembersCheck.h"
24 #include "AvoidDoWhileCheck.h"
25 #include "AvoidGotoCheck.h"
26 #include "AvoidNonConstGlobalVariablesCheck.h"
27 #include "AvoidReferenceCoroutineParametersCheck.h"
28 #include "InitVariablesCheck.h"
29 #include "InterfacesGlobalInitCheck.h"
30 #include "MacroUsageCheck.h"
31 #include "MisleadingCaptureDefaultByValueCheck.h"
32 #include "MissingStdForwardCheck.h"
33 #include "NarrowingConversionsCheck.h"
34 #include "NoMallocCheck.h"
35 #include "NoSuspendWithLockCheck.h"
36 #include "OwningMemoryCheck.h"
37 #include "PreferMemberInitializerCheck.h"
38 #include "ProBoundsArrayToPointerDecayCheck.h"
39 #include "ProBoundsConstantArrayIndexCheck.h"
40 #include "ProBoundsPointerArithmeticCheck.h"
41 #include "ProTypeConstCastCheck.h"
42 #include "ProTypeCstyleCastCheck.h"
43 #include "ProTypeMemberInitCheck.h"
44 #include "ProTypeReinterpretCastCheck.h"
45 #include "ProTypeStaticCastDowncastCheck.h"
46 #include "ProTypeUnionAccessCheck.h"
47 #include "ProTypeVarargCheck.h"
48 #include "RvalueReferenceParamNotMovedCheck.h"
49 #include "SlicingCheck.h"
50 #include "SpecialMemberFunctionsCheck.h"
51 #include "VirtualClassDestructorCheck.h"
53 namespace clang::tidy {
54 namespace cppcoreguidelines {
56 /// A module containing checks of the C++ Core Guidelines
57 class CppCoreGuidelinesModule : public ClangTidyModule {
58 public:
59 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
60 CheckFactories.registerCheck<AvoidCapturingLambdaCoroutinesCheck>(
61 "cppcoreguidelines-avoid-capturing-lambda-coroutines");
62 CheckFactories.registerCheck<modernize::AvoidCArraysCheck>(
63 "cppcoreguidelines-avoid-c-arrays");
64 CheckFactories.registerCheck<AvoidConstOrRefDataMembersCheck>(
65 "cppcoreguidelines-avoid-const-or-ref-data-members");
66 CheckFactories.registerCheck<AvoidDoWhileCheck>(
67 "cppcoreguidelines-avoid-do-while");
68 CheckFactories.registerCheck<AvoidGotoCheck>(
69 "cppcoreguidelines-avoid-goto");
70 CheckFactories.registerCheck<readability::MagicNumbersCheck>(
71 "cppcoreguidelines-avoid-magic-numbers");
72 CheckFactories.registerCheck<AvoidNonConstGlobalVariablesCheck>(
73 "cppcoreguidelines-avoid-non-const-global-variables");
74 CheckFactories.registerCheck<AvoidReferenceCoroutineParametersCheck>(
75 "cppcoreguidelines-avoid-reference-coroutine-parameters");
76 CheckFactories.registerCheck<modernize::UseOverrideCheck>(
77 "cppcoreguidelines-explicit-virtual-functions");
78 CheckFactories.registerCheck<InitVariablesCheck>(
79 "cppcoreguidelines-init-variables");
80 CheckFactories.registerCheck<InterfacesGlobalInitCheck>(
81 "cppcoreguidelines-interfaces-global-init");
82 CheckFactories.registerCheck<modernize::MacroToEnumCheck>(
83 "cppcoreguidelines-macro-to-enum");
84 CheckFactories.registerCheck<MacroUsageCheck>(
85 "cppcoreguidelines-macro-usage");
86 CheckFactories.registerCheck<MisleadingCaptureDefaultByValueCheck>(
87 "cppcoreguidelines-misleading-capture-default-by-value");
88 CheckFactories.registerCheck<MissingStdForwardCheck>(
89 "cppcoreguidelines-missing-std-forward");
90 CheckFactories.registerCheck<NarrowingConversionsCheck>(
91 "cppcoreguidelines-narrowing-conversions");
92 CheckFactories.registerCheck<NoMallocCheck>("cppcoreguidelines-no-malloc");
93 CheckFactories.registerCheck<NoSuspendWithLockCheck>(
94 "cppcoreguidelines-no-suspend-with-lock");
95 CheckFactories.registerCheck<performance::NoexceptDestructorCheck>(
96 "cppcoreguidelines-noexcept-destructor");
97 CheckFactories.registerCheck<performance::NoexceptMoveConstructorCheck>(
98 "cppcoreguidelines-noexcept-move-operations");
99 CheckFactories.registerCheck<performance::NoexceptSwapCheck>(
100 "cppcoreguidelines-noexcept-swap");
101 CheckFactories.registerCheck<misc::NonPrivateMemberVariablesInClassesCheck>(
102 "cppcoreguidelines-non-private-member-variables-in-classes");
103 CheckFactories.registerCheck<OwningMemoryCheck>(
104 "cppcoreguidelines-owning-memory");
105 CheckFactories.registerCheck<PreferMemberInitializerCheck>(
106 "cppcoreguidelines-prefer-member-initializer");
107 CheckFactories.registerCheck<ProBoundsArrayToPointerDecayCheck>(
108 "cppcoreguidelines-pro-bounds-array-to-pointer-decay");
109 CheckFactories.registerCheck<ProBoundsConstantArrayIndexCheck>(
110 "cppcoreguidelines-pro-bounds-constant-array-index");
111 CheckFactories.registerCheck<ProBoundsPointerArithmeticCheck>(
112 "cppcoreguidelines-pro-bounds-pointer-arithmetic");
113 CheckFactories.registerCheck<ProTypeConstCastCheck>(
114 "cppcoreguidelines-pro-type-const-cast");
115 CheckFactories.registerCheck<ProTypeCstyleCastCheck>(
116 "cppcoreguidelines-pro-type-cstyle-cast");
117 CheckFactories.registerCheck<ProTypeMemberInitCheck>(
118 "cppcoreguidelines-pro-type-member-init");
119 CheckFactories.registerCheck<ProTypeReinterpretCastCheck>(
120 "cppcoreguidelines-pro-type-reinterpret-cast");
121 CheckFactories.registerCheck<ProTypeStaticCastDowncastCheck>(
122 "cppcoreguidelines-pro-type-static-cast-downcast");
123 CheckFactories.registerCheck<ProTypeUnionAccessCheck>(
124 "cppcoreguidelines-pro-type-union-access");
125 CheckFactories.registerCheck<ProTypeVarargCheck>(
126 "cppcoreguidelines-pro-type-vararg");
127 CheckFactories.registerCheck<RvalueReferenceParamNotMovedCheck>(
128 "cppcoreguidelines-rvalue-reference-param-not-moved");
129 CheckFactories.registerCheck<SpecialMemberFunctionsCheck>(
130 "cppcoreguidelines-special-member-functions");
131 CheckFactories.registerCheck<SlicingCheck>("cppcoreguidelines-slicing");
132 CheckFactories.registerCheck<modernize::UseDefaultMemberInitCheck>(
133 "cppcoreguidelines-use-default-member-init");
134 CheckFactories.registerCheck<misc::UnconventionalAssignOperatorCheck>(
135 "cppcoreguidelines-c-copy-assignment-signature");
136 CheckFactories.registerCheck<VirtualClassDestructorCheck>(
137 "cppcoreguidelines-virtual-class-destructor");
140 ClangTidyOptions getModuleOptions() override {
141 ClangTidyOptions Options;
142 ClangTidyOptions::OptionMap &Opts = Options.CheckOptions;
144 Opts["cppcoreguidelines-non-private-member-variables-in-classes."
145 "IgnoreClassesWithAllMemberVariablesBeingPublic"] = "true";
147 return Options;
151 // Register the LLVMTidyModule using this statically initialized variable.
152 static ClangTidyModuleRegistry::Add<CppCoreGuidelinesModule>
153 X("cppcoreguidelines-module", "Adds checks for the C++ Core Guidelines.");
155 } // namespace cppcoreguidelines
157 // This anchor is used to force the linker to link in the generated object file
158 // and thus register the CppCoreGuidelinesModule.
159 volatile int CppCoreGuidelinesModuleAnchorSource = 0;
161 } // namespace clang::tidy