1 //===--- BugproneTidyModule.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 "../cppcoreguidelines/NarrowingConversionsCheck.h" 13 #include "ArgumentCommentCheck.h" 14 #include "AssertSideEffectCheck.h" 15 #include "BadSignalToKillThreadCheck.h" 16 #include "BoolPointerImplicitConversionCheck.h" 17 #include "BranchCloneCheck.h" 18 #include "CopyConstructorInitCheck.h" 19 #include "DanglingHandleCheck.h" 20 #include "DynamicStaticInitializersCheck.h" 21 #include "EasilySwappableParametersCheck.h" 22 #include "ExceptionEscapeCheck.h" 23 #include "FoldInitTypeCheck.h" 24 #include "ForwardDeclarationNamespaceCheck.h" 25 #include "ForwardingReferenceOverloadCheck.h" 26 #include "ImplicitWideningOfMultiplicationResultCheck.h" 27 #include "InaccurateEraseCheck.h" 28 #include "IncorrectRoundingsCheck.h" 29 #include "InfiniteLoopCheck.h" 30 #include "IntegerDivisionCheck.h" 31 #include "LambdaFunctionNameCheck.h" 32 #include "MacroParenthesesCheck.h" 33 #include "MacroRepeatedSideEffectsCheck.h" 34 #include "MisplacedOperatorInStrlenInAllocCheck.h" 35 #include "MisplacedPointerArithmeticInAllocCheck.h" 36 #include "MisplacedWideningCastCheck.h" 37 #include "MoveForwardingReferenceCheck.h" 38 #include "MultipleStatementMacroCheck.h" 39 #include "NoEscapeCheck.h" 40 #include "NotNullTerminatedResultCheck.h" 41 #include "ParentVirtualCallCheck.h" 42 #include "PosixReturnCheck.h" 43 #include "RedundantBranchConditionCheck.h" 44 #include "ReservedIdentifierCheck.h" 45 #include "SignalHandlerCheck.h" 46 #include "SignedCharMisuseCheck.h" 47 #include "SizeofContainerCheck.h" 48 #include "SizeofExpressionCheck.h" 49 #include "SpuriouslyWakeUpFunctionsCheck.h" 50 #include "StringConstructorCheck.h" 51 #include "StringIntegerAssignmentCheck.h" 52 #include "StringLiteralWithEmbeddedNulCheck.h" 53 #include "SuspiciousEnumUsageCheck.h" 54 #include "SuspiciousIncludeCheck.h" 55 #include "SuspiciousMemsetUsageCheck.h" 56 #include "SuspiciousMissingCommaCheck.h" 57 #include "SuspiciousSemicolonCheck.h" 58 #include "SuspiciousStringCompareCheck.h" 59 #include "SwappedArgumentsCheck.h" 60 #include "TerminatingContinueCheck.h" 61 #include "ThrowKeywordMissingCheck.h" 62 #include "TooSmallLoopVariableCheck.h" 63 #include "UndefinedMemoryManipulationCheck.h" 64 #include "UndelegatedConstructorCheck.h" 65 #include "UnhandledExceptionAtNewCheck.h" 66 #include "UnhandledSelfAssignmentCheck.h" 67 #include "UnusedRaiiCheck.h" 68 #include "UnusedReturnValueCheck.h" 69 #include "UseAfterMoveCheck.h" 70 #include "VirtualNearMissCheck.h" 71 72 namespace clang { 73 namespace tidy { 74 namespace bugprone { 75 76 class BugproneModule : public ClangTidyModule { 77 public: 78 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { 79 CheckFactories.registerCheck<ArgumentCommentCheck>( 80 "bugprone-argument-comment"); 81 CheckFactories.registerCheck<AssertSideEffectCheck>( 82 "bugprone-assert-side-effect"); 83 CheckFactories.registerCheck<BadSignalToKillThreadCheck>( 84 "bugprone-bad-signal-to-kill-thread"); 85 CheckFactories.registerCheck<BoolPointerImplicitConversionCheck>( 86 "bugprone-bool-pointer-implicit-conversion"); 87 CheckFactories.registerCheck<BranchCloneCheck>( 88 "bugprone-branch-clone"); 89 CheckFactories.registerCheck<CopyConstructorInitCheck>( 90 "bugprone-copy-constructor-init"); 91 CheckFactories.registerCheck<DanglingHandleCheck>( 92 "bugprone-dangling-handle"); 93 CheckFactories.registerCheck<DynamicStaticInitializersCheck>( 94 "bugprone-dynamic-static-initializers"); 95 CheckFactories.registerCheck<EasilySwappableParametersCheck>( 96 "bugprone-easily-swappable-parameters"); 97 CheckFactories.registerCheck<ExceptionEscapeCheck>( 98 "bugprone-exception-escape"); 99 CheckFactories.registerCheck<FoldInitTypeCheck>( 100 "bugprone-fold-init-type"); 101 CheckFactories.registerCheck<ForwardDeclarationNamespaceCheck>( 102 "bugprone-forward-declaration-namespace"); 103 CheckFactories.registerCheck<ForwardingReferenceOverloadCheck>( 104 "bugprone-forwarding-reference-overload"); 105 CheckFactories.registerCheck<ImplicitWideningOfMultiplicationResultCheck>( 106 "bugprone-implicit-widening-of-multiplication-result"); 107 CheckFactories.registerCheck<InaccurateEraseCheck>( 108 "bugprone-inaccurate-erase"); 109 CheckFactories.registerCheck<IncorrectRoundingsCheck>( 110 "bugprone-incorrect-roundings"); 111 CheckFactories.registerCheck<InfiniteLoopCheck>( 112 "bugprone-infinite-loop"); 113 CheckFactories.registerCheck<IntegerDivisionCheck>( 114 "bugprone-integer-division"); 115 CheckFactories.registerCheck<LambdaFunctionNameCheck>( 116 "bugprone-lambda-function-name"); 117 CheckFactories.registerCheck<MacroParenthesesCheck>( 118 "bugprone-macro-parentheses"); 119 CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>( 120 "bugprone-macro-repeated-side-effects"); 121 CheckFactories.registerCheck<MisplacedOperatorInStrlenInAllocCheck>( 122 "bugprone-misplaced-operator-in-strlen-in-alloc"); 123 CheckFactories.registerCheck<MisplacedPointerArithmeticInAllocCheck>( 124 "bugprone-misplaced-pointer-arithmetic-in-alloc"); 125 CheckFactories.registerCheck<MisplacedWideningCastCheck>( 126 "bugprone-misplaced-widening-cast"); 127 CheckFactories.registerCheck<MoveForwardingReferenceCheck>( 128 "bugprone-move-forwarding-reference"); 129 CheckFactories.registerCheck<MultipleStatementMacroCheck>( 130 "bugprone-multiple-statement-macro"); 131 CheckFactories.registerCheck<RedundantBranchConditionCheck>( 132 "bugprone-redundant-branch-condition"); 133 CheckFactories.registerCheck<cppcoreguidelines::NarrowingConversionsCheck>( 134 "bugprone-narrowing-conversions"); 135 CheckFactories.registerCheck<NoEscapeCheck>("bugprone-no-escape"); 136 CheckFactories.registerCheck<NotNullTerminatedResultCheck>( 137 "bugprone-not-null-terminated-result"); 138 CheckFactories.registerCheck<ParentVirtualCallCheck>( 139 "bugprone-parent-virtual-call"); 140 CheckFactories.registerCheck<PosixReturnCheck>( 141 "bugprone-posix-return"); 142 CheckFactories.registerCheck<ReservedIdentifierCheck>( 143 "bugprone-reserved-identifier"); 144 CheckFactories.registerCheck<SignalHandlerCheck>("bugprone-signal-handler"); 145 CheckFactories.registerCheck<SignedCharMisuseCheck>( 146 "bugprone-signed-char-misuse"); 147 CheckFactories.registerCheck<SizeofContainerCheck>( 148 "bugprone-sizeof-container"); 149 CheckFactories.registerCheck<SizeofExpressionCheck>( 150 "bugprone-sizeof-expression"); 151 CheckFactories.registerCheck<SpuriouslyWakeUpFunctionsCheck>( 152 "bugprone-spuriously-wake-up-functions"); 153 CheckFactories.registerCheck<StringConstructorCheck>( 154 "bugprone-string-constructor"); 155 CheckFactories.registerCheck<StringIntegerAssignmentCheck>( 156 "bugprone-string-integer-assignment"); 157 CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>( 158 "bugprone-string-literal-with-embedded-nul"); 159 CheckFactories.registerCheck<SuspiciousEnumUsageCheck>( 160 "bugprone-suspicious-enum-usage"); 161 CheckFactories.registerCheck<SuspiciousIncludeCheck>( 162 "bugprone-suspicious-include"); 163 CheckFactories.registerCheck<SuspiciousMemsetUsageCheck>( 164 "bugprone-suspicious-memset-usage"); 165 CheckFactories.registerCheck<SuspiciousMissingCommaCheck>( 166 "bugprone-suspicious-missing-comma"); 167 CheckFactories.registerCheck<SuspiciousSemicolonCheck>( 168 "bugprone-suspicious-semicolon"); 169 CheckFactories.registerCheck<SuspiciousStringCompareCheck>( 170 "bugprone-suspicious-string-compare"); 171 CheckFactories.registerCheck<SwappedArgumentsCheck>( 172 "bugprone-swapped-arguments"); 173 CheckFactories.registerCheck<TerminatingContinueCheck>( 174 "bugprone-terminating-continue"); 175 CheckFactories.registerCheck<ThrowKeywordMissingCheck>( 176 "bugprone-throw-keyword-missing"); 177 CheckFactories.registerCheck<TooSmallLoopVariableCheck>( 178 "bugprone-too-small-loop-variable"); 179 CheckFactories.registerCheck<UndefinedMemoryManipulationCheck>( 180 "bugprone-undefined-memory-manipulation"); 181 CheckFactories.registerCheck<UndelegatedConstructorCheck>( 182 "bugprone-undelegated-constructor"); 183 CheckFactories.registerCheck<UnhandledSelfAssignmentCheck>( 184 "bugprone-unhandled-self-assignment"); 185 CheckFactories.registerCheck<UnhandledExceptionAtNewCheck>( 186 "bugprone-unhandled-exception-at-new"); 187 CheckFactories.registerCheck<UnusedRaiiCheck>( 188 "bugprone-unused-raii"); 189 CheckFactories.registerCheck<UnusedReturnValueCheck>( 190 "bugprone-unused-return-value"); 191 CheckFactories.registerCheck<UseAfterMoveCheck>( 192 "bugprone-use-after-move"); 193 CheckFactories.registerCheck<VirtualNearMissCheck>( 194 "bugprone-virtual-near-miss"); 195 } 196 }; 197 198 } // namespace bugprone 199 200 // Register the BugproneTidyModule using this statically initialized variable. 201 static ClangTidyModuleRegistry::Add<bugprone::BugproneModule> 202 X("bugprone-module", "Adds checks for bugprone code constructs."); 203 204 // This anchor is used to force the linker to link in the generated object file 205 // and thus register the BugproneModule. 206 volatile int BugproneModuleAnchorSource = 0; 207 208 } // namespace tidy 209 } // namespace clang 210