clang-tools 20.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 "AvoidEndlCheck.h"
13#include "EnumSizeCheck.h"
15#include "ForRangeCopyCheck.h"
20#include "MoveConstArgCheck.h"
23#include "NoIntToPtrCheck.h"
26#include "NoexceptSwapCheck.h"
31
32namespace clang::tidy {
33namespace performance {
34
36public:
37 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
38 CheckFactories.registerCheck<AvoidEndlCheck>("performance-avoid-endl");
39 CheckFactories.registerCheck<EnumSizeCheck>("performance-enum-size");
41 "performance-faster-string-find");
42 CheckFactories.registerCheck<ForRangeCopyCheck>(
43 "performance-for-range-copy");
45 "performance-implicit-conversion-in-loop");
47 "performance-inefficient-algorithm");
49 "performance-inefficient-string-concatenation");
51 "performance-inefficient-vector-operation");
52 CheckFactories.registerCheck<MoveConstArgCheck>(
53 "performance-move-const-arg");
55 "performance-move-constructor-init");
56 CheckFactories.registerCheck<NoAutomaticMoveCheck>(
57 "performance-no-automatic-move");
58 CheckFactories.registerCheck<NoIntToPtrCheck>("performance-no-int-to-ptr");
60 "performance-noexcept-destructor");
62 "performance-noexcept-move-constructor");
63 CheckFactories.registerCheck<NoexceptSwapCheck>(
64 "performance-noexcept-swap");
66 "performance-trivially-destructible");
68 "performance-type-promotion-in-math-fn");
70 "performance-unnecessary-copy-initialization");
72 "performance-unnecessary-value-param");
73 }
74};
75
76// Register the PerformanceModule using this statically initialized variable.
77static ClangTidyModuleRegistry::Add<PerformanceModule>
78 X("performance-module", "Adds performance checks.");
79
80} // namespace performance
81
82// This anchor is used to force the linker to link in the generated object file
83// and thus register the PerformanceModule.
85
86} // namespace clang::tidy
int X
A collection of ClangTidyCheckFactory instances.
void registerCheck(llvm::StringRef CheckName)
Registers the CheckType with the name Name.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
ClangTidyCheck Checks to flag for uses of 'std::endl' on streams and suggests using the newline chara...
Finds enum type definitions that could use smaller integral type as a base.
Definition: EnumSizeCheck.h:22
Optimize calls to std::string::find() and friends when the needle passed is a single character string...
A check that detects copied loop variables and suggests using const references.
Warns on inefficient use of STL algorithms on associative containers.
This check is to warn about the performance overhead arising from concatenating strings,...
Finds possible inefficient std::vector operations (e.g.
Find casts of calculation results to bigger type.
The check flags user-defined move constructors that have a ctor-initializer initializing a member or ...
Finds local variables that cannot be automatically moved due to constness.
Diagnoses every integer to pointer cast.
The check flags destructors not marked with noexcept or marked with noexcept(expr) where expr evaluat...
The check flags user-defined move constructors and assignment operators not marked with noexcept or m...
The check flags swap functions not marked with noexcept or marked with noexcept(expr) where expr eval...
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
A check that finds classes that would be trivial if not for the defaulted destructors declared out-of...
Finds calls to C math library functions with implicit float to double promotions.
A check that flags value parameters of expensive to copy types that can safely be converted to const ...
volatile int PerformanceModuleAnchorSource