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