1 //===--- PeformanceTidyModule.cpp - clang-tidy ----------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "../ClangTidy.h" 11 #include "../ClangTidyModule.h" 12 #include "../ClangTidyModuleRegistry.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 "MoveConstructorInitCheck.h" 20 #include "TypePromotionInMathFnCheck.h" 21 #include "UnnecessaryCopyInitialization.h" 22 #include "UnnecessaryValueParamCheck.h" 23 24 namespace clang { 25 namespace tidy { 26 namespace performance { 27 28 class PerformanceModule : public ClangTidyModule { 29 public: 30 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { 31 CheckFactories.registerCheck<FasterStringFindCheck>( 32 "performance-faster-string-find"); 33 CheckFactories.registerCheck<ForRangeCopyCheck>( 34 "performance-for-range-copy"); 35 CheckFactories.registerCheck<ImplicitConversionInLoopCheck>( 36 "performance-implicit-conversion-in-loop"); 37 CheckFactories.registerCheck<InefficientAlgorithmCheck>( 38 "performance-inefficient-algorithm"); 39 CheckFactories.registerCheck<InefficientStringConcatenationCheck>( 40 "performance-inefficient-string-concatenation"); 41 CheckFactories.registerCheck<InefficientVectorOperationCheck>( 42 "performance-inefficient-vector-operation"); 43 CheckFactories.registerCheck<MoveConstructorInitCheck>( 44 "performance-move-constructor-init"); 45 CheckFactories.registerCheck<TypePromotionInMathFnCheck>( 46 "performance-type-promotion-in-math-fn"); 47 CheckFactories.registerCheck<UnnecessaryCopyInitialization>( 48 "performance-unnecessary-copy-initialization"); 49 CheckFactories.registerCheck<UnnecessaryValueParamCheck>( 50 "performance-unnecessary-value-param"); 51 } 52 }; 53 54 // Register the PerformanceModule using this statically initialized variable. 55 static ClangTidyModuleRegistry::Add<PerformanceModule> 56 X("performance-module", "Adds performance checks."); 57 58 } // namespace performance 59 60 // This anchor is used to force the linker to link in the generated object file 61 // and thus register the PerformanceModule. 62 volatile int PerformanceModuleAnchorSource = 0; 63 64 } // namespace tidy 65 } // namespace clang 66