clang-tools 19.0.0git
Go to the documentation of this file.
1//===--- GoogleTidyModule.cpp - clang-tidy --------------------------------===//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9#include "../ClangTidy.h"
10#include "../ClangTidyModule.h"
11#include "../ClangTidyModuleRegistry.h"
12#include "../readability/BracesAroundStatementsCheck.h"
13#include "../readability/FunctionSizeCheck.h"
14#include "../readability/NamespaceCommentCheck.h"
22#include "FunctionNamingCheck.h"
25#include "IntegerTypesCheck.h"
27#include "TodoCommentCheck.h"
32using namespace clang::ast_matchers;
34namespace clang::tidy {
35namespace google {
38 public:
39 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
41 "google-build-explicit-make-pair");
43 "google-build-namespaces");
45 "google-build-using-namespace");
47 "google-default-arguments");
49 "google-explicit-constructor");
51 "google-global-names-in-headers");
53 "google-objc-avoid-nsobject-new");
55 "google-objc-avoid-throwing-exception");
57 "google-objc-function-naming");
59 "google-objc-global-variable-declaration");
61 "google-runtime-int");
63 "google-runtime-operator");
64 CheckFactories
66 "google-readability-avoid-underscore-in-googletest-name");
68 "google-readability-casting");
70 "google-readability-todo");
71 CheckFactories
73 "google-readability-braces-around-statements");
75 "google-readability-function-size");
76 CheckFactories
78 "google-readability-namespace-comments");
80 "google-upgrade-googletest-case");
81 }
84 ClangTidyOptions Options;
85 auto &Opts = Options.CheckOptions;
86 Opts["google-readability-braces-around-statements.ShortStatementLines"] =
87 "1";
88 Opts["google-readability-function-size.StatementThreshold"] = "800";
89 Opts["google-readability-namespace-comments.ShortNamespaceLines"] = "10";
90 Opts["google-readability-namespace-comments.SpacesBeforeComments"] = "2";
91 return Options;
92 }
95// Register the GoogleTidyModule using this statically initialized variable.
96static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
97 "Adds Google lint checks.");
99} // namespace google
101// This anchor is used to force the linker to link in the generated object file
102// and thus register the GoogleModule.
105} // 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.
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:
Flag global namespace pollution in header files.
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)?...
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.
volatile int GoogleModuleAnchorSource
Contains options for clang-tidy.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.