| 1 |
//===--- ModernizeTidyModule.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 "AvoidBindCheck.h" |
| 13 |
#include "AvoidCArraysCheck.h" |
| 14 |
#include "ConcatNestedNamespacesCheck.h" |
| 15 |
#include "DeprecatedHeadersCheck.h" |
| 16 |
#include "DeprecatedIosBaseAliasesCheck.h" |
| 17 |
#include "LoopConvertCheck.h" |
| 18 |
#include "MacroToEnumCheck.h" |
| 19 |
#include "MakeSharedCheck.h" |
| 20 |
#include "MakeUniqueCheck.h" |
| 21 |
#include "MinMaxUseInitializerListCheck.h" |
| 22 |
#include "PassByValueCheck.h" |
| 23 |
#include "RawStringLiteralCheck.h" |
| 24 |
#include "RedundantVoidArgCheck.h" |
| 25 |
#include "ReplaceAutoPtrCheck.h" |
| 26 |
#include "ReplaceDisallowCopyAndAssignMacroCheck.h" |
| 27 |
#include "ReplaceRandomShuffleCheck.h" |
| 28 |
#include "ReturnBracedInitListCheck.h" |
| 29 |
#include "ShrinkToFitCheck.h" |
| 30 |
#include "TypeTraitsCheck.h" |
| 31 |
#include "UnaryStaticAssertCheck.h" |
| 32 |
#include "UseAutoCheck.h" |
| 33 |
#include "UseBoolLiteralsCheck.h" |
| 34 |
#include "UseConstraintsCheck.h" |
| 35 |
#include "UseDefaultMemberInitCheck.h" |
| 36 |
#include "UseDesignatedInitializersCheck.h" |
| 37 |
#include "UseEmplaceCheck.h" |
| 38 |
#include "UseEqualsDefaultCheck.h" |
| 39 |
#include "UseEqualsDeleteCheck.h" |
| 40 |
#include "UseNodiscardCheck.h" |
| 41 |
#include "UseNoexceptCheck.h" |
| 42 |
#include "UseNullptrCheck.h" |
| 43 |
#include "UseOverrideCheck.h" |
| 44 |
#include "UseRangesCheck.h" |
| 45 |
#include "UseStartsEndsWithCheck.h" |
| 46 |
#include "UseStdFormatCheck.h" |
| 47 |
#include "UseStdNumbersCheck.h" |
| 48 |
#include "UseStdPrintCheck.h" |
| 49 |
#include "UseTrailingReturnTypeCheck.h" |
| 50 |
#include "UseTransparentFunctorsCheck.h" |
| 51 |
#include "UseUncaughtExceptionsCheck.h" |
| 52 |
#include "UseUsingCheck.h" |
| 53 |
|
| 54 |
using namespace clang::ast_matchers; |
| 55 |
|
| 56 |
namespace clang::tidy { |
| 57 |
namespace modernize { |
| 58 |
|
| 59 |
class ModernizeModule : public ClangTidyModule { |
| 60 |
public: |
| 61 |
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
| 62 |
CheckFactories.registerCheck<AvoidBindCheck>("modernize-avoid-bind"); |
| 63 |
CheckFactories.registerCheck<AvoidCArraysCheck>("modernize-avoid-c-arrays"); |
| 64 |
CheckFactories.registerCheck<ConcatNestedNamespacesCheck>( |
| 65 |
"modernize-concat-nested-namespaces"); |
| 66 |
CheckFactories.registerCheck<DeprecatedHeadersCheck>( |
| 67 |
"modernize-deprecated-headers"); |
| 68 |
CheckFactories.registerCheck<DeprecatedIosBaseAliasesCheck>( |
| 69 |
"modernize-deprecated-ios-base-aliases"); |
| 70 |
CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert"); |
| 71 |
CheckFactories.registerCheck<MacroToEnumCheck>("modernize-macro-to-enum"); |
| 72 |
CheckFactories.registerCheck<MakeSharedCheck>("modernize-make-shared"); |
| 73 |
CheckFactories.registerCheck<MakeUniqueCheck>("modernize-make-unique"); |
| 74 |
CheckFactories.registerCheck<MinMaxUseInitializerListCheck>( |
| 75 |
"modernize-min-max-use-initializer-list"); |
| 76 |
CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value"); |
| 77 |
CheckFactories.registerCheck<UseDesignatedInitializersCheck>( |
| 78 |
"modernize-use-designated-initializers"); |
| 79 |
CheckFactories.registerCheck<UseRangesCheck>("modernize-use-ranges"); |
| 80 |
CheckFactories.registerCheck<UseStartsEndsWithCheck>( |
| 81 |
"modernize-use-starts-ends-with"); |
| 82 |
CheckFactories.registerCheck<UseStdFormatCheck>("modernize-use-std-format"); |
| 83 |
CheckFactories.registerCheck<UseStdNumbersCheck>( |
| 84 |
"modernize-use-std-numbers"); |
| 85 |
CheckFactories.registerCheck<UseStdPrintCheck>("modernize-use-std-print"); |
| 86 |
CheckFactories.registerCheck<RawStringLiteralCheck>( |
| 87 |
"modernize-raw-string-literal"); |
| 88 |
CheckFactories.registerCheck<RedundantVoidArgCheck>( |
| 89 |
"modernize-redundant-void-arg"); |
| 90 |
CheckFactories.registerCheck<ReplaceAutoPtrCheck>( |
| 91 |
"modernize-replace-auto-ptr"); |
| 92 |
CheckFactories.registerCheck<ReplaceDisallowCopyAndAssignMacroCheck>( |
| 93 |
"modernize-replace-disallow-copy-and-assign-macro"); |
| 94 |
CheckFactories.registerCheck<ReplaceRandomShuffleCheck>( |
| 95 |
"modernize-replace-random-shuffle"); |
| 96 |
CheckFactories.registerCheck<ReturnBracedInitListCheck>( |
| 97 |
"modernize-return-braced-init-list"); |
| 98 |
CheckFactories.registerCheck<ShrinkToFitCheck>("modernize-shrink-to-fit"); |
| 99 |
CheckFactories.registerCheck<TypeTraitsCheck>("modernize-type-traits"); |
| 100 |
CheckFactories.registerCheck<UnaryStaticAssertCheck>( |
| 101 |
"modernize-unary-static-assert"); |
| 102 |
CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto"); |
| 103 |
CheckFactories.registerCheck<UseBoolLiteralsCheck>( |
| 104 |
"modernize-use-bool-literals"); |
| 105 |
CheckFactories.registerCheck<UseConstraintsCheck>( |
| 106 |
"modernize-use-constraints"); |
| 107 |
CheckFactories.registerCheck<UseDefaultMemberInitCheck>( |
| 108 |
"modernize-use-default-member-init"); |
| 109 |
CheckFactories.registerCheck<UseEmplaceCheck>("modernize-use-emplace"); |
| 110 |
CheckFactories.registerCheck<UseEqualsDefaultCheck>("modernize-use-equals-default"); |
| 111 |
CheckFactories.registerCheck<UseEqualsDeleteCheck>( |
| 112 |
"modernize-use-equals-delete"); |
| 113 |
CheckFactories.registerCheck<UseNodiscardCheck>( |
| 114 |
"modernize-use-nodiscard"); |
| 115 |
CheckFactories.registerCheck<UseNoexceptCheck>("modernize-use-noexcept"); |
| 116 |
CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr"); |
| 117 |
CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override"); |
| 118 |
CheckFactories.registerCheck<UseTrailingReturnTypeCheck>( |
| 119 |
"modernize-use-trailing-return-type"); |
| 120 |
CheckFactories.registerCheck<UseTransparentFunctorsCheck>( |
| 121 |
"modernize-use-transparent-functors"); |
| 122 |
CheckFactories.registerCheck<UseUncaughtExceptionsCheck>( |
| 123 |
"modernize-use-uncaught-exceptions"); |
| 124 |
CheckFactories.registerCheck<UseUsingCheck>("modernize-use-using"); |
| 125 |
} |
| 126 |
}; |
| 127 |
|
| 128 |
// Register the ModernizeTidyModule using this statically initialized variable. |
| 129 |
static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module", |
| 130 |
"Add modernize checks."); |
| 131 |
|
| 132 |
} // namespace modernize |
| 133 |
|
| 134 |
// This anchor is used to force the linker to link in the generated object file |
| 135 |
// and thus register the ModernizeModule. |
| 136 |
volatile int ModernizeModuleAnchorSource = 0; |
| 137 |
|
| 138 |
} // namespace clang::tidy |