clang-tools 6.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"
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 "NoexceptMoveConstructorCheck.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<TypePromotionInMathFnCheck>(
52 "performance-type-promotion-in-math-fn");
53 CheckFactories.registerCheck<UnnecessaryCopyInitialization>(
54 "performance-unnecessary-copy-initialization");
55 CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
56 "performance-unnecessary-value-param");
57 }
58 };
59
60 // Register the PerformanceModule using this statically initialized variable.
61 static ClangTidyModuleRegistry::Add<PerformanceModule>
62 X("performance-module", "Adds performance checks.");
63
64 } // namespace performance
65
66 // This anchor is used to force the linker to link in the generated object file
67 // and thus register the PerformanceModule.
68 volatile int PerformanceModuleAnchorSource = 0;
69
70 } // namespace tidy
71 } // namespace clang
clang::tidy::performance::UnnecessaryCopyInitialization
Definition: UnnecessaryCopyInitialization.h:27
MoveConstArgCheck.h
clang::tidy::performance::NoexceptMoveConstructorCheck
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Definition: NoexceptMoveConstructorCheck.h:26
clang::tidy::performance::X
static ClangTidyModuleRegistry::Add< PerformanceModule > X("performance-module", "Adds performance checks.")
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
clang::tidy::performance::InefficientAlgorithmCheck
Warns on inefficient use of STL algorithms on associative containers.
Definition: InefficientAlgorithmCheck.h:24
clang::tidy::performance::InefficientVectorOperationCheck
Finds possible inefficient std::vector operations (e.g.
Definition: InefficientVectorOperationCheck.h:24
FasterStringFindCheck.h
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:27
ForRangeCopyCheck.h
clang::tidy::performance::InefficientStringConcatenationCheck
This check is to warn about the performance overhead arising from concatenating strings, using the operator+, instead of operator+=.
Definition: InefficientStringConcatenationCheck.h:25
clang::tidy::PerformanceModuleAnchorSource
volatile int PerformanceModuleAnchorSource
Definition: PerformanceTidyModule.cpp:68
clang::tidy::performance::FasterStringFindCheck
Optimize calls to std::string::find() and friends when the needle passed is a single character string...
Definition: FasterStringFindCheck.h:28
clang::tidy::performance::TypePromotionInMathFnCheck
Finds calls to C math library functions with implicit float to double promotions. ...
Definition: TypePromotionInMathFnCheck.h:29
InefficientVectorOperationCheck.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:84
clang::tidy::performance::MoveConstructorInitCheck
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Definition: MoveConstructorInitCheck.h:27
InefficientStringConcatenationCheck.h
clang::tidy::performance::PerformanceModule::addCheckFactories
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Definition: PerformanceTidyModule.cpp:32
clang::tidy::performance::UnnecessaryValueParamCheck
A check that flags value parameters of expensive to copy types that can safely be converted to const ...
Definition: UnnecessaryValueParamCheck.h:25
ImplicitConversionInLoopCheck.h
TypePromotionInMathFnCheck.h
clang::tidy::performance::ImplicitConversionInLoopCheck
Definition: ImplicitConversionInLoopCheck.h:22
NoexceptMoveConstructorCheck.h
clang
Definition: AndroidTidyModule.cpp:28
UnnecessaryValueParamCheck.h
clang::tidy::performance::ForRangeCopyCheck
A check that detects copied loop variables and suggests using const references.
Definition: ForRangeCopyCheck.h:23
clang::tidy::performance::PerformanceModule
Definition: PerformanceTidyModule.cpp:30
InefficientAlgorithmCheck.h
clang::tidy::performance::MoveConstArgCheck
Find casts of calculation results to bigger type.
Definition: MoveConstArgCheck.h:25
MoveConstructorInitCheck.h
UnnecessaryCopyInitialization.h