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