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