xref: /llvm-project/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp (revision f1a6552a95ef359317405b6b905e452c0577d22c)
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 "InefficientStringConcatenationCheck.h"
17 #include "InefficientVectorOperationCheck.h"
18 #include "TypePromotionInMathFnCheck.h"
19 #include "UnnecessaryCopyInitialization.h"
20 #include "UnnecessaryValueParamCheck.h"
21 
22 namespace clang {
23 namespace tidy {
24 namespace performance {
25 
26 class PerformanceModule : public ClangTidyModule {
27 public:
28   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
29     CheckFactories.registerCheck<FasterStringFindCheck>(
30         "performance-faster-string-find");
31     CheckFactories.registerCheck<ForRangeCopyCheck>(
32         "performance-for-range-copy");
33     CheckFactories.registerCheck<ImplicitConversionInLoopCheck>(
34         "performance-implicit-conversion-in-loop");
35     CheckFactories.registerCheck<InefficientStringConcatenationCheck>(
36         "performance-inefficient-string-concatenation");
37     CheckFactories.registerCheck<InefficientVectorOperationCheck>(
38         "performance-inefficient-vector-operation");
39     CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
40         "performance-type-promotion-in-math-fn");
41     CheckFactories.registerCheck<UnnecessaryCopyInitialization>(
42         "performance-unnecessary-copy-initialization");
43     CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
44         "performance-unnecessary-value-param");
45   }
46 };
47 
48 // Register the PerformanceModule using this statically initialized variable.
49 static ClangTidyModuleRegistry::Add<PerformanceModule>
50     X("performance-module", "Adds performance checks.");
51 
52 } // namespace performance
53 
54 // This anchor is used to force the linker to link in the generated object file
55 // and thus register the PerformanceModule.
56 volatile int PerformanceModuleAnchorSource = 0;
57 
58 } // namespace tidy
59 } // namespace clang
60