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