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