clang-tools 22.0.0git
GoogleTidyModule.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"
22#include "FloatTypesCheck.h"
23#include "FunctionNamingCheck.h"
26#include "IntegerTypesCheck.h"
28#include "TodoCommentCheck.h"
32
33using namespace clang::ast_matchers;
34
35namespace clang::tidy {
36namespace google {
37
39public:
40 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
42 "google-build-explicit-make-pair");
44 "google-build-namespaces");
46 "google-build-using-namespace");
48 "google-default-arguments");
50 "google-explicit-constructor");
52 "google-global-names-in-headers");
54 "google-objc-avoid-nsobject-new");
56 "google-objc-avoid-throwing-exception");
58 "google-objc-function-naming");
60 "google-objc-global-variable-declaration");
62 "google-runtime-float");
64 "google-runtime-int");
66 "google-runtime-operator");
67 CheckFactories
69 "google-readability-avoid-underscore-in-googletest-name");
71 "google-readability-casting");
73 "google-readability-todo");
74 CheckFactories
76 "google-readability-braces-around-statements");
78 "google-readability-function-size");
79 CheckFactories
81 "google-readability-namespace-comments");
83 "google-upgrade-googletest-case");
84 }
85
87 ClangTidyOptions Options;
88 auto &Opts = Options.CheckOptions;
89 Opts["google-readability-braces-around-statements.ShortStatementLines"] =
90 "1";
91 Opts["google-readability-function-size.StatementThreshold"] = "800";
92 Opts["google-readability-namespace-comments.ShortNamespaceLines"] = "10";
93 Opts["google-readability-namespace-comments.SpacesBeforeComments"] = "2";
94 return Options;
95 }
96};
97
98// Register the GoogleTidyModule using this statically initialized variable.
99static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
100 "Adds Google lint checks.");
101
102} // namespace google
103
104// This anchor is used to force the linker to link in the generated object file
105// and thus register the GoogleModule.
106volatile int GoogleModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage)
107
108} // namespace clang::tidy
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.
Checks that default parameters are not given for virtual methods.
Checks that all single-argument constructors are explicit.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module.
ClangTidyOptions getModuleOptions() override
Gets default options for checks defined in this module.
Finds uses of deprecated Googletest APIs with names containing "case" and replaces them with equivale...
Check that make_pair's template arguments are deduced.
This check finds Objective-C code that uses +new to create object instances, or overrides +new in cla...
Finds function names that do not conform to the recommendations of the Google Objective-C Style Guide...
The check for Objective-C global variables and constants naming convention.
For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/google/readabil...
Finds TODO comments without a username or bug number.
Finds uses of short, long and long long and suggest replacing them with u?intXX(_t)?...
Finds usages of long double and suggests against their use due to lack of portability.
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
Checks for large functions based on various metrics.
Checks that long namespaces have a closing comment.
static ClangTidyModuleRegistry::Add< GoogleModule > X("google-module", "Adds Google lint checks.")
volatile int GoogleModuleAnchorSource
Contains options for clang-tidy.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.