clang-tools 18.0.0git
ModernizeTidyModule.cpp
Go to the documentation of this file.
1//===--- ModernizeTidyModule.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 "AvoidBindCheck.h"
13#include "AvoidCArraysCheck.h"
17#include "LoopConvertCheck.h"
18#include "MacroToEnumCheck.h"
19#include "MakeSharedCheck.h"
20#include "MakeUniqueCheck.h"
21#include "PassByValueCheck.h"
24#include "ReplaceAutoPtrCheck.h"
28#include "ShrinkToFitCheck.h"
29#include "TypeTraitsCheck.h"
31#include "UseAutoCheck.h"
33#include "UseConstraintsCheck.h"
35#include "UseEmplaceCheck.h"
38#include "UseNodiscardCheck.h"
39#include "UseNoexceptCheck.h"
40#include "UseNullptrCheck.h"
41#include "UseOverrideCheck.h"
43#include "UseStdNumbersCheck.h"
44#include "UseStdPrintCheck.h"
48#include "UseUsingCheck.h"
49
50using namespace clang::ast_matchers;
51
52namespace clang::tidy {
53namespace modernize {
54
56public:
57 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
58 CheckFactories.registerCheck<AvoidBindCheck>("modernize-avoid-bind");
59 CheckFactories.registerCheck<AvoidCArraysCheck>("modernize-avoid-c-arrays");
61 "modernize-concat-nested-namespaces");
63 "modernize-deprecated-headers");
65 "modernize-deprecated-ios-base-aliases");
66 CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");
67 CheckFactories.registerCheck<MacroToEnumCheck>("modernize-macro-to-enum");
68 CheckFactories.registerCheck<MakeSharedCheck>("modernize-make-shared");
69 CheckFactories.registerCheck<MakeUniqueCheck>("modernize-make-unique");
70 CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
72 "modernize-use-starts-ends-with");
73 CheckFactories.registerCheck<UseStdNumbersCheck>(
74 "modernize-use-std-numbers");
75 CheckFactories.registerCheck<UseStdPrintCheck>("modernize-use-std-print");
77 "modernize-raw-string-literal");
79 "modernize-redundant-void-arg");
80 CheckFactories.registerCheck<ReplaceAutoPtrCheck>(
81 "modernize-replace-auto-ptr");
83 "modernize-replace-disallow-copy-and-assign-macro");
85 "modernize-replace-random-shuffle");
87 "modernize-return-braced-init-list");
88 CheckFactories.registerCheck<ShrinkToFitCheck>("modernize-shrink-to-fit");
89 CheckFactories.registerCheck<TypeTraitsCheck>("modernize-type-traits");
91 "modernize-unary-static-assert");
92 CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
93 CheckFactories.registerCheck<UseBoolLiteralsCheck>(
94 "modernize-use-bool-literals");
95 CheckFactories.registerCheck<UseConstraintsCheck>(
96 "modernize-use-constraints");
98 "modernize-use-default-member-init");
99 CheckFactories.registerCheck<UseEmplaceCheck>("modernize-use-emplace");
100 CheckFactories.registerCheck<UseEqualsDefaultCheck>("modernize-use-equals-default");
101 CheckFactories.registerCheck<UseEqualsDeleteCheck>(
102 "modernize-use-equals-delete");
103 CheckFactories.registerCheck<UseNodiscardCheck>(
104 "modernize-use-nodiscard");
105 CheckFactories.registerCheck<UseNoexceptCheck>("modernize-use-noexcept");
106 CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
107 CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override");
109 "modernize-use-trailing-return-type");
111 "modernize-use-transparent-functors");
113 "modernize-use-uncaught-exceptions");
114 CheckFactories.registerCheck<UseUsingCheck>("modernize-use-using");
115 }
116};
117
118// Register the ModernizeTidyModule using this statically initialized variable.
119static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module",
120 "Add modernize checks.");
121
122} // namespace modernize
123
124// This anchor is used to force the linker to link in the generated object file
125// and thus register the ModernizeModule.
127
128} // 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.
Replace simple uses of std::bind with a lambda.
Find C-style array types and recommend to use std::array<> / std::vector<>.
This check replaces deprecated C library headers with their C++ STL alternatives.
This check warns the uses of the deprecated member types of std::ios_base and replaces those that hav...
Replaces groups of related macros with an unscoped anonymous enum.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
This check replaces string literals with escaped characters to raw string literals.
Find and remove redundant void argument lists.
Transforms the deprecated std::auto_ptr into the C++11 std::unique_ptr.
This check finds macro expansions of DISALLOW_COPY_AND_ASSIGN(Type) and replaces them with a deleted ...
std::random_shuffle will be removed as of C++17.
Use a braced init list for return statements rather than unnecessary repeating the return type name.
Replace copy and swap tricks on shrinkable containers with the shrink_to_fit() method call.
Converts standard library type traits of the form traits<...>::type and traits<......
Replaces a static_assert declaration with an empty message with the unary version.
Finds integer literals which are cast to bool.
Replace enable_if with C++20 requires clauses.
Convert a default constructor's member initializers into default member initializers.
This check looks for cases when inserting new element into std::vector but the element is constructed...
Replace default bodies of special member functions with '= default;'.
Identifies unimplemented private special member functions, and recommends using = delete for them.
Add [[nodiscard]] to non-void const-member functions with no arguments or pass-by-value or pass by co...
Replace dynamic exception specifications, with noexcept (or user-defined macro) or noexcept(false).
Use C++11's override and remove virtual where applicable.
Checks whether a find or rfind result is compared with 0 and suggests replacing with starts_with when...
Finds constants and function calls to math functions that can be replaced with c++20's mathematical c...
Convert calls to printf-like functions to std::print and std::println.
Rewrites function signatures to use a trailing return type.
Prefer using transparent functors to non-transparent ones.
This check will warn on calls to std::uncaught_exception and replace them with calls to std::uncaught...
Check finds typedefs and replaces it with usings.
Definition: UseUsingCheck.h:20
volatile int ModernizeModuleAnchorSource