clang-tools 24.0.0git
PerformanceTidyModule.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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 "AvoidEndlCheck.h"
12#include "EnumSizeCheck.h"
14#include "ForRangeCopyCheck.h"
19#include "MoveConstArgCheck.h"
22#include "NoIntToPtrCheck.h"
25#include "NoexceptSwapCheck.h"
32#include "UseStdMoveCheck.h"
33
34namespace clang::tidy {
35namespace performance {
36namespace {
37
38class PerformanceModule : public ClangTidyModule {
39public:
40 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
41 CheckFactories.registerCheck<AvoidEndlCheck>("performance-avoid-endl");
42 CheckFactories.registerCheck<EnumSizeCheck>("performance-enum-size");
43 CheckFactories.registerCheck<ExpensiveValueOrCheck>(
44 "performance-expensive-value-or");
45 CheckFactories.registerCheck<PreferSingleCharOverloadsCheck>(
46 "performance-faster-string-find");
47 CheckFactories.registerCheck<ForRangeCopyCheck>(
48 "performance-for-range-copy");
49 CheckFactories.registerCheck<ImplicitConversionInLoopCheck>(
50 "performance-implicit-conversion-in-loop");
51 CheckFactories.registerCheck<InefficientAlgorithmCheck>(
52 "performance-inefficient-algorithm");
53 CheckFactories.registerCheck<InefficientStringConcatenationCheck>(
54 "performance-inefficient-string-concatenation");
55 CheckFactories.registerCheck<InefficientVectorOperationCheck>(
56 "performance-inefficient-vector-operation");
57 CheckFactories.registerCheck<MoveConstArgCheck>(
58 "performance-move-const-arg");
59 CheckFactories.registerCheck<MoveConstructorInitCheck>(
60 "performance-move-constructor-init");
61 CheckFactories.registerCheck<NoAutomaticMoveCheck>(
62 "performance-no-automatic-move");
63 CheckFactories.registerCheck<NoIntToPtrCheck>("performance-no-int-to-ptr");
64 CheckFactories.registerCheck<NoexceptDestructorCheck>(
65 "performance-noexcept-destructor");
66 CheckFactories.registerCheck<NoexceptMoveConstructorCheck>(
67 "performance-noexcept-move-constructor");
68 CheckFactories.registerCheck<NoexceptSwapCheck>(
69 "performance-noexcept-swap");
70 CheckFactories.registerCheck<PreferSingleCharOverloadsCheck>(
71 "performance-prefer-single-char-overloads");
72 CheckFactories.registerCheck<StringViewConversionsCheck>(
73 "performance-string-view-conversions");
74 CheckFactories.registerCheck<TriviallyDestructibleCheck>(
75 "performance-trivially-destructible");
76 CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
77 "performance-type-promotion-in-math-fn");
78 CheckFactories.registerCheck<UnnecessaryCopyInitializationCheck>(
79 "performance-unnecessary-copy-initialization");
80 CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
81 "performance-unnecessary-value-param");
82 CheckFactories.registerCheck<UseStdMoveCheck>("performance-use-std-move");
83 }
84};
85
86} // namespace
87
88// Register the PerformanceModule using this statically initialized variable.
89static ClangTidyModuleRegistry::Add<PerformanceModule>
90 X("performance-module", "Adds performance checks.");
91
92} // namespace performance
93
94// This anchor is used to force the linker to link in the generated object file
95// and thus register the PerformanceModule.
96// NOLINTNEXTLINE(misc-use-internal-linkage)
98
99} // namespace clang::tidy
static ClangTidyModuleRegistry::Add< PerformanceModule > X("performance-module", "Adds performance checks.")
volatile int PerformanceModuleAnchorSource