| 1 | //===-- PerformanceTidyModule.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 "AvoidEndlCheck.h" |
| 13 | #include "EnumSizeCheck.h" |
| 14 | #include "FasterStringFindCheck.h" |
| 15 | #include "ForRangeCopyCheck.h" |
| 16 | #include "ImplicitConversionInLoopCheck.h" |
| 17 | #include "InefficientAlgorithmCheck.h" |
| 18 | #include "InefficientStringConcatenationCheck.h" |
| 19 | #include "InefficientVectorOperationCheck.h" |
| 20 | #include "MoveConstArgCheck.h" |
| 21 | #include "MoveConstructorInitCheck.h" |
| 22 | #include "NoAutomaticMoveCheck.h" |
| 23 | #include "NoIntToPtrCheck.h" |
| 24 | #include "NoexceptDestructorCheck.h" |
| 25 | #include "NoexceptMoveConstructorCheck.h" |
| 26 | #include "NoexceptSwapCheck.h" |
| 27 | #include "TriviallyDestructibleCheck.h" |
| 28 | #include "TypePromotionInMathFnCheck.h" |
| 29 | #include "UnnecessaryCopyInitialization.h" |
| 30 | #include "UnnecessaryValueParamCheck.h" |
| 31 | |
| 32 | namespace clang::tidy { |
| 33 | namespace performance { |
| 34 | |
| 35 | class PerformanceModule : public ClangTidyModule { |
| 36 | public: |
| 37 | void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { |
| 38 | CheckFactories.registerCheck<AvoidEndlCheck>(CheckName: "performance-avoid-endl"); |
| 39 | CheckFactories.registerCheck<EnumSizeCheck>(CheckName: "performance-enum-size"); |
| 40 | CheckFactories.registerCheck<FasterStringFindCheck>( |
| 41 | CheckName: "performance-faster-string-find"); |
| 42 | CheckFactories.registerCheck<ForRangeCopyCheck>( |
| 43 | CheckName: "performance-for-range-copy"); |
| 44 | CheckFactories.registerCheck<ImplicitConversionInLoopCheck>( |
| 45 | CheckName: "performance-implicit-conversion-in-loop"); |
| 46 | CheckFactories.registerCheck<InefficientAlgorithmCheck>( |
| 47 | CheckName: "performance-inefficient-algorithm"); |
| 48 | CheckFactories.registerCheck<InefficientStringConcatenationCheck>( |
| 49 | CheckName: "performance-inefficient-string-concatenation"); |
| 50 | CheckFactories.registerCheck<InefficientVectorOperationCheck>( |
| 51 | CheckName: "performance-inefficient-vector-operation"); |
| 52 | CheckFactories.registerCheck<MoveConstArgCheck>( |
| 53 | CheckName: "performance-move-const-arg"); |
| 54 | CheckFactories.registerCheck<MoveConstructorInitCheck>( |
| 55 | CheckName: "performance-move-constructor-init"); |
| 56 | CheckFactories.registerCheck<NoAutomaticMoveCheck>( |
| 57 | CheckName: "performance-no-automatic-move"); |
| 58 | CheckFactories.registerCheck<NoIntToPtrCheck>(CheckName: "performance-no-int-to-ptr"); |
| 59 | CheckFactories.registerCheck<NoexceptDestructorCheck>( |
| 60 | CheckName: "performance-noexcept-destructor"); |
| 61 | CheckFactories.registerCheck<NoexceptMoveConstructorCheck>( |
| 62 | CheckName: "performance-noexcept-move-constructor"); |
| 63 | CheckFactories.registerCheck<NoexceptSwapCheck>( |
| 64 | CheckName: "performance-noexcept-swap"); |
| 65 | CheckFactories.registerCheck<TriviallyDestructibleCheck>( |
| 66 | CheckName: "performance-trivially-destructible"); |
| 67 | CheckFactories.registerCheck<TypePromotionInMathFnCheck>( |
| 68 | CheckName: "performance-type-promotion-in-math-fn"); |
| 69 | CheckFactories.registerCheck<UnnecessaryCopyInitialization>( |
| 70 | CheckName: "performance-unnecessary-copy-initialization"); |
| 71 | CheckFactories.registerCheck<UnnecessaryValueParamCheck>( |
| 72 | CheckName: "performance-unnecessary-value-param"); |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | // Register the PerformanceModule using this statically initialized variable. |
| 77 | static ClangTidyModuleRegistry::Add<PerformanceModule> |
| 78 | X("performance-module", "Adds performance checks."); |
| 79 | |
| 80 | } // namespace performance |
| 81 | |
| 82 | // This anchor is used to force the linker to link in the generated object file |
| 83 | // and thus register the PerformanceModule. |
| 84 | // NOLINTNEXTLINE(misc-use-internal-linkage) |
| 85 | volatile int PerformanceModuleAnchorSource = 0; |
| 86 | |
| 87 | } // namespace clang::tidy |
| 88 |
