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