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"
14#include "ForRangeCopyCheck.h"
19#include "MoveConstArgCheck.h"
22#include "NoIntToPtrCheck.h"
25#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<FasterStringFindCheck>(
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<StringViewConversionsCheck>(
68 "performance-string-view-conversions");
69 CheckFactories.registerCheck<TriviallyDestructibleCheck>(
70 "performance-trivially-destructible");
71 CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
72 "performance-type-promotion-in-math-fn");
73 CheckFactories.registerCheck<UnnecessaryCopyInitializationCheck>(
74 "performance-unnecessary-copy-initialization");
75 CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
76 "performance-unnecessary-value-param");
77 CheckFactories.registerCheck<UseStdMoveCheck>("performance-use-std-move");
78 }
79};
80
81} // namespace
82
83// Register the PerformanceModule using this statically initialized variable.
84static ClangTidyModuleRegistry::Add<PerformanceModule>
85 X("performance-module", "Adds performance checks.");
86
87} // namespace performance
88
89// This anchor is used to force the linker to link in the generated object file
90// and thus register the PerformanceModule.
91// NOLINTNEXTLINE(misc-use-internal-linkage)
93
94} // namespace clang::tidy
static ClangTidyModuleRegistry::Add< PerformanceModule > X("performance-module", "Adds performance checks.")
volatile int PerformanceModuleAnchorSource