clang-tools  4.0.0
PerformanceTidyModule.cpp
Go to the documentation of this file.
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"
20 
21 namespace clang {
22 namespace tidy {
23 namespace performance {
24 
26 public:
27  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
28  CheckFactories.registerCheck<FasterStringFindCheck>(
29  "performance-faster-string-find");
30  CheckFactories.registerCheck<ForRangeCopyCheck>(
31  "performance-for-range-copy");
32  CheckFactories.registerCheck<ImplicitCastInLoopCheck>(
33  "performance-implicit-cast-in-loop");
35  "performance-inefficient-string-concatenation");
37  "performance-type-promotion-in-math-fn");
39  "performance-unnecessary-copy-initialization");
41  "performance-unnecessary-value-param");
42  }
43 };
44 
45 // Register the PerformanceModule using this statically initialized variable.
46 static ClangTidyModuleRegistry::Add<PerformanceModule>
47  X("performance-module", "Adds performance checks.");
48 
49 } // namespace performance
50 
51 // This anchor is used to force the linker to link in the generated object file
52 // and thus register the PerformanceModule.
54 
55 } // namespace tidy
56 } // namespace clang
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
A collection of ClangTidyCheckFactory instances.
This check is to warn about the performance overhead arising from concatenating strings, using the operator+, instead of operator+=.
volatile int PerformanceModuleAnchorSource
Optimize calls to std::string::find() and friends when the needle passed is a single character string...
Finds calls to C math library functions with implicit float to double promotions. ...
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
A check that flags value parameters of expensive to copy types that can safely be converted to const ...
A check that detects copied loop variables and suggests using const references.
static ClangTidyModuleRegistry::Add< PerformanceModule > X("performance-module","Adds performance checks.")