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