clang-tools  7.0.0
GoogleTidyModule.cpp
Go to the documentation of this file.
1 //===--- GoogleTidyModule.cpp - clang-tidy --------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "../ClangTidy.h"
11 #include "../ClangTidyModule.h"
12 #include "../ClangTidyModuleRegistry.h"
13 #include "../readability/BracesAroundStatementsCheck.h"
14 #include "../readability/FunctionSizeCheck.h"
15 #include "../readability/NamespaceCommentCheck.h"
16 #include "AvoidCStyleCastsCheck.h"
18 #include "DefaultArgumentsCheck.h"
20 #include "ExplicitMakePairCheck.h"
23 #include "IntegerTypesCheck.h"
24 #include "NonConstReferences.h"
26 #include "TodoCommentCheck.h"
29 
30 using namespace clang::ast_matchers;
31 
32 namespace clang {
33 namespace tidy {
34 namespace google {
35 
36 class GoogleModule : public ClangTidyModule {
37  public:
38  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
40  "google-build-explicit-make-pair");
42  "google-build-namespaces");
44  "google-build-using-namespace");
45  CheckFactories.registerCheck<DefaultArgumentsCheck>(
46  "google-default-arguments");
48  "google-explicit-constructor");
50  "google-global-names-in-headers");
52  "google-objc-avoid-throwing-exception");
54  "google-objc-global-variable-declaration");
56  "google-runtime-int");
58  "google-runtime-operator");
60  "google-runtime-references");
62  "google-readability-casting");
64  "google-readability-todo");
65  CheckFactories
67  "google-readability-braces-around-statements");
69  "google-readability-function-size");
70  CheckFactories
72  "google-readability-namespace-comments");
73  }
74 
76  ClangTidyOptions Options;
77  auto &Opts = Options.CheckOptions;
78  Opts["google-readability-braces-around-statements.ShortStatementLines"] =
79  "1";
80  Opts["google-readability-function-size.StatementThreshold"] = "800";
81  Opts["google-readability-namespace-comments.ShortNamespaceLines"] = "10";
82  Opts["google-readability-namespace-comments.SpacesBeforeComments"] = "2";
83  return Options;
84  }
85 };
86 
87 // Register the GoogleTidyModule using this statically initialized variable.
88 static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
89  "Adds Google lint checks.");
90 
91 } // namespace google
92 
93 // This anchor is used to force the linker to link in the generated object file
94 // and thus register the GoogleModule.
95 volatile int GoogleModuleAnchorSource = 0;
96 
97 } // namespace tidy
98 } // namespace clang
volatile int GoogleModuleAnchorSource
void registerCheck(StringRef CheckName)
Registers the CheckType with the name Name.
Flag global namespace pollution in header files.
Checks that default parameters are not given for virtual methods.
Contains options for clang-tidy.
Checks the usage of non-constant references in function parameters.
Check that make_pair&#39;s template arguments are deduced.
A collection of ClangTidyCheckFactory instances.
OptionMap CheckOptions
Key-value mapping used to store check-specific options.
static ClangTidyModuleRegistry::Add< GoogleModule > X("google-module", "Adds Google lint checks.")
Checks for large functions based on various metrics.
A clang-tidy module groups a number of ClangTidyChecks and gives them a prefixed name.
ClangTidyOptions getModuleOptions() override
Gets default options for checks defined in this module.
Finds uses of short, long and long long and suggest replacing them with u?intXX(_t)?.
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override
Implement this function in order to register all CheckFactories belonging to this module...
Finds TODO comments without a username or bug number.
Checks that long namespaces have a closing comment.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Checks that bodies of if statements and loops (for, range-for, do-while, and while) are inside braces...
The check for Objective-C global variables and constants naming convention.
Checks that all single-argument constructors are explicit.