clang-tools 20.0.0git
GoogleTidyModule.cpp
Go to the documentation of this file.
1//===--- GoogleTidyModule.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 "../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"
31
32using namespace clang::ast_matchers;
33
34namespace clang::tidy {
35namespace google {
36
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 }
82
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 }
93};
94
95// Register the GoogleTidyModule using this statically initialized variable.
96static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
97 "Adds Google lint checks.");
98
99} // namespace google
100
101// This anchor is used to force the linker to link in the generated object file
102// and thus register the GoogleModule.
104
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: http://clang.llvm.org/extra/clang-tidy/checks/google/readabili...
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.