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