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