blob: 1681727061c3a69d8d96b8d76ac61e06c86c8614 [file] [log] [blame]
Daniel Jasperd07c8402013-07-29 08:19:24 +00001//===--- 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
Daniel Jasperd07c8402013-07-29 08:19:24 +000010#include "../ClangTidy.h"
11#include "../ClangTidyModule.h"
12#include "../ClangTidyModuleRegistry.h"
Alexander Kornienko276fc642014-06-29 22:19:53 +000013#include "AvoidCStyleCastsCheck.h"
Alexander Kornienko72f1e752014-06-18 09:33:46 +000014#include "ExplicitConstructorCheck.h"
Benjamin Kramer47c4d102014-07-15 09:50:32 +000015#include "ExplicitMakePairCheck.h"
Benjamin Kramerebab1502014-07-16 14:30:19 +000016#include "MemsetZeroLengthCheck.h"
Benjamin Kramer14d42d92014-07-15 16:47:09 +000017#include "NamedParameterCheck.h"
Benjamin Kramerfeff1342014-07-15 12:48:14 +000018#include "OverloadedUnaryAndCheck.h"
Benjamin Kramerb1039752014-07-16 10:00:14 +000019#include "StringReferenceMemberCheck.h"
Benjamin Kramer2252cbf2014-07-16 14:16:56 +000020#include "UnnamedNamespaceInHeaderCheck.h"
21#include "UsingNamespaceDirectiveCheck.h"
Daniel Jasperd07c8402013-07-29 08:19:24 +000022
23using namespace clang::ast_matchers;
24
25namespace clang {
26namespace tidy {
27
Daniel Jasperd07c8402013-07-29 08:19:24 +000028class GoogleModule : public ClangTidyModule {
29public:
Alexander Kornienko21f3b772014-03-05 13:01:24 +000030 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Daniel Jasperd07c8402013-07-29 08:19:24 +000031 CheckFactories.addCheckFactory(
Benjamin Kramer47c4d102014-07-15 09:50:32 +000032 "google-build-explicit-make-pair",
33 new ClangTidyCheckFactory<build::ExplicitMakePairCheck>());
34 CheckFactories.addCheckFactory(
Benjamin Kramer2252cbf2014-07-16 14:16:56 +000035 "google-build-namespaces",
36 new ClangTidyCheckFactory<build::UnnamedNamespaceInHeaderCheck>());
37 CheckFactories.addCheckFactory(
38 "google-build-using-namespace",
39 new ClangTidyCheckFactory<build::UsingNamespaceDirectiveCheck>());
40 CheckFactories.addCheckFactory(
Daniel Jasperd07c8402013-07-29 08:19:24 +000041 "google-explicit-constructor",
42 new ClangTidyCheckFactory<ExplicitConstructorCheck>());
Alexander Kornienko276fc642014-06-29 22:19:53 +000043 CheckFactories.addCheckFactory(
Benjamin Kramerfeff1342014-07-15 12:48:14 +000044 "google-runtime-operator",
45 new ClangTidyCheckFactory<runtime::OverloadedUnaryAndCheck>());
46 CheckFactories.addCheckFactory(
Benjamin Kramerb1039752014-07-16 10:00:14 +000047 "google-runtime-member-string-references",
48 new ClangTidyCheckFactory<runtime::StringReferenceMemberCheck>());
49 CheckFactories.addCheckFactory(
Benjamin Kramerebab1502014-07-16 14:30:19 +000050 "google-runtime-memset",
51 new ClangTidyCheckFactory<runtime::MemsetZeroLengthCheck>());
52 CheckFactories.addCheckFactory(
Alexander Kornienko276fc642014-06-29 22:19:53 +000053 "google-readability-casting",
54 new ClangTidyCheckFactory<readability::AvoidCStyleCastsCheck>());
Benjamin Kramer14d42d92014-07-15 16:47:09 +000055 CheckFactories.addCheckFactory(
56 "google-readability-function",
57 new ClangTidyCheckFactory<readability::NamedParameterCheck>());
Daniel Jasperd07c8402013-07-29 08:19:24 +000058 }
59};
60
61// Register the GoogleTidyModule using this statically initialized variable.
62static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
63 "Adds Google lint checks.");
64
65// This anchor is used to force the linker to link in the generated object file
66// and thus register the GoogleModule.
67volatile int GoogleModuleAnchorSource = 0;
68
69} // namespace tidy
70} // namespace clang