clang-tools  14.0.0git
PerformanceTidyModule.cpp
Go to the documentation of this file.
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"
18 #include "MoveConstArgCheck.h"
20 #include "NoAutomaticMoveCheck.h"
21 #include "NoIntToPtrCheck.h"
27 
28 namespace clang {
29 namespace tidy {
30 namespace performance {
31 
33 public:
34  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
35  CheckFactories.registerCheck<FasterStringFindCheck>(
36  "performance-faster-string-find");
37  CheckFactories.registerCheck<ForRangeCopyCheck>(
38  "performance-for-range-copy");
40  "performance-implicit-conversion-in-loop");
42  "performance-inefficient-algorithm");
44  "performance-inefficient-string-concatenation");
46  "performance-inefficient-vector-operation");
47  CheckFactories.registerCheck<MoveConstArgCheck>(
48  "performance-move-const-arg");
50  "performance-move-constructor-init");
51  CheckFactories.registerCheck<NoAutomaticMoveCheck>(
52  "performance-no-automatic-move");
53  CheckFactories.registerCheck<NoIntToPtrCheck>("performance-no-int-to-ptr");
55  "performance-noexcept-move-constructor");
57  "performance-trivially-destructible");
59  "performance-type-promotion-in-math-fn");
61  "performance-unnecessary-copy-initialization");
63  "performance-unnecessary-value-param");
64  }
65 };
66 
67 // Register the PerformanceModule using this statically initialized variable.
68 static ClangTidyModuleRegistry::Add<PerformanceModule>
69  X("performance-module", "Adds performance checks.");
70 
71 } // namespace performance
72 
73 // This anchor is used to force the linker to link in the generated object file
74 // and thus register the PerformanceModule.
76 
77 } // namespace tidy
78 } // namespace clang
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:34
InefficientVectorOperationCheck.h
ImplicitConversionInLoopCheck.h
NoexceptMoveConstructorCheck.h
clang::tidy::performance::MoveConstructorInitCheck
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Definition: MoveConstructorInitCheck.h:23
clang::tidy::performance::TypePromotionInMathFnCheck
Finds calls to C math library functions with implicit float to double promotions.
Definition: TypePromotionInMathFnCheck.h:28
clang::tidy::performance::NoAutomaticMoveCheck
Finds local variables that cannot be automatically moved due to constness.
Definition: NoAutomaticMoveCheck.h:21
clang::tidy::PerformanceModuleAnchorSource
volatile int PerformanceModuleAnchorSource
Definition: PerformanceTidyModule.cpp:75
NoIntToPtrCheck.h
FasterStringFindCheck.h
clang::tidy::performance::TriviallyDestructibleCheck
A check that finds classes that would be trivial if not for the defaulted destructors declared out-of...
Definition: TriviallyDestructibleCheck.h:28
clang::tidy::performance::MoveConstArgCheck
Find casts of calculation results to bigger type.
Definition: MoveConstArgCheck.h:24
clang::tidy::ClangTidyCheckFactories
A collection of ClangTidyCheckFactory instances.
Definition: ClangTidyModule.h:28
InefficientStringConcatenationCheck.h
InefficientAlgorithmCheck.h
clang::tidy::performance::InefficientVectorOperationCheck
Finds possible inefficient std::vector operations (e.g.
Definition: InefficientVectorOperationCheck.h:26
clang::tidy::performance::UnnecessaryCopyInitialization
Definition: UnnecessaryCopyInitialization.h:27
clang::tidy::performance::InefficientAlgorithmCheck
Warns on inefficient use of STL algorithms on associative containers.
Definition: InefficientAlgorithmCheck.h:23
clang::tidy::performance::InefficientStringConcatenationCheck
This check is to warn about the performance overhead arising from concatenating strings,...
Definition: InefficientStringConcatenationCheck.h:24
clang::tidy::performance::FasterStringFindCheck
Optimize calls to std::string::find() and friends when the needle passed is a single character string...
Definition: FasterStringFindCheck.h:27
clang::tidy::performance::PerformanceModule
Definition: PerformanceTidyModule.cpp:32
clang::tidy::performance::NoexceptMoveConstructorCheck
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
Definition: NoexceptMoveConstructorCheck.h:25
clang::tidy::performance::ImplicitConversionInLoopCheck
Definition: ImplicitConversionInLoopCheck.h:21
clang::tidy::performance::ForRangeCopyCheck
A check that detects copied loop variables and suggests using const references.
Definition: ForRangeCopyCheck.h:22
MoveConstArgCheck.h
clang::tidy::performance::NoIntToPtrCheck
Diagnoses every integer to pointer cast.
Definition: NoIntToPtrCheck.h:22
UnnecessaryValueParamCheck.h
NoAutomaticMoveCheck.h
MoveConstructorInitCheck.h
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
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
ForRangeCopyCheck.h
clang::tidy::performance::X
static ClangTidyModuleRegistry::Add< PerformanceModule > X("performance-module", "Adds performance checks.")
TriviallyDestructibleCheck.h
clang::tidy::ClangTidyModule
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
Definition: ClangTidyModule.h:81
UnnecessaryCopyInitialization.h
clang::tidy::ClangTidyCheckFactories::registerCheck
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
Definition: ClangTidyModule.h:59
TypePromotionInMathFnCheck.h