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"
31
32using namespace clang::ast_matchers;
33
34namespace clang::tidy {
35namespace google {
36namespace {
37
38class GoogleModule : public ClangTidyModule {
39public:
40 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
41 CheckFactories.registerCheck<build::ExplicitMakePairCheck>(
42 "google-build-explicit-make-pair");
43 CheckFactories.registerCheck<misc::AnonymousNamespaceInHeaderCheck>(
44 "google-build-namespaces");
45 CheckFactories.registerCheck<build::UsingNamespaceDirectiveCheck>(
46 "google-build-using-namespace");
47 CheckFactories.registerCheck<DefaultArgumentsCheck>(
48 "google-default-arguments");
49 CheckFactories.registerCheck<ExplicitConstructorCheck>(
50 "google-explicit-constructor");
51 CheckFactories.registerCheck<readability::GlobalNamesInHeadersCheck>(
52 "google-global-names-in-headers");
53 CheckFactories.registerCheck<objc::AvoidNSObjectNewCheck>(
54 "google-objc-avoid-nsobject-new");
55 CheckFactories.registerCheck<objc::AvoidThrowingObjCExceptionCheck>(
56 "google-objc-avoid-throwing-exception");
57 CheckFactories.registerCheck<objc::FunctionNamingCheck>(
58 "google-objc-function-naming");
59 CheckFactories.registerCheck<objc::GlobalVariableDeclarationCheck>(
60 "google-objc-global-variable-declaration");
61 CheckFactories.registerCheck<runtime::RuntimeFloatCheck>(
62 "google-runtime-float");
63 CheckFactories.registerCheck<runtime::IntegerTypesCheck>(
64 "google-runtime-int");
65 CheckFactories.registerCheck<runtime::OverloadedUnaryAndCheck>(
66 "google-runtime-operator");
67 CheckFactories
68 .registerCheck<readability::AvoidUnderscoreInGoogletestNameCheck>(
69 "google-readability-avoid-underscore-in-googletest-name");
70 CheckFactories.registerCheck<modernize::AvoidCStyleCastCheck>(
71 "google-readability-casting");
72 CheckFactories.registerCheck<readability::TodoCommentCheck>(
73 "google-readability-todo");
74 CheckFactories
75 .registerCheck<clang::tidy::readability::BracesAroundStatementsCheck>(
76 "google-readability-braces-around-statements");
77 CheckFactories.registerCheck<clang::tidy::readability::FunctionSizeCheck>(
78 "google-readability-function-size");
79 CheckFactories
80 .registerCheck<clang::tidy::readability::NamespaceCommentCheck>(
81 "google-readability-namespace-comments");
82 CheckFactories.registerCheck<UpgradeGoogletestCaseCheck>(
83 "google-upgrade-googletest-case");
84 }
85
86 ClangTidyOptions getModuleOptions() override {
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} // namespace
99
100// Register the GoogleTidyModule using this statically initialized variable.
101static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
102 "Adds Google lint checks.");
103
104} // namespace google
105
106// This anchor is used to force the linker to link in the generated object file
107// and thus register the GoogleModule.
108volatile int GoogleModuleAnchorSource = 0; // NOLINT(misc-use-internal-linkage)
109
110} // namespace clang::tidy
static ClangTidyModuleRegistry::Add< GoogleModule > X("google-module", "Adds Google lint checks.")
volatile int GoogleModuleAnchorSource
OptionMap CheckOptions
Key-value mapping used to store check-specific options.