blob: 416f48d1fa3588cf74dee655682cef7e3e1a90f6 [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 Kramer14d42d92014-07-15 16:47:09 +000016#include "NamedParameterCheck.h"
Benjamin Kramerfeff1342014-07-15 12:48:14 +000017#include "OverloadedUnaryAndCheck.h"
Benjamin Kramerb1039752014-07-16 10:00:14 +000018#include "StringReferenceMemberCheck.h"
Benjamin Kramer2252cbf2014-07-16 14:16:56 +000019#include "UnnamedNamespaceInHeaderCheck.h"
20#include "UsingNamespaceDirectiveCheck.h"
Daniel Jasperd07c8402013-07-29 08:19:24 +000021
22using namespace clang::ast_matchers;
23
24namespace clang {
25namespace tidy {
26
Daniel Jasperd07c8402013-07-29 08:19:24 +000027class GoogleModule : public ClangTidyModule {
28public:
Alexander Kornienko21f3b772014-03-05 13:01:24 +000029 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Daniel Jasperd07c8402013-07-29 08:19:24 +000030 CheckFactories.addCheckFactory(
Benjamin Kramer47c4d102014-07-15 09:50:32 +000031 "google-build-explicit-make-pair",
32 new ClangTidyCheckFactory<build::ExplicitMakePairCheck>());
33 CheckFactories.addCheckFactory(
Benjamin Kramer2252cbf2014-07-16 14:16:56 +000034 "google-build-namespaces",
35 new ClangTidyCheckFactory<build::UnnamedNamespaceInHeaderCheck>());
36 CheckFactories.addCheckFactory(
37 "google-build-using-namespace",
38 new ClangTidyCheckFactory<build::UsingNamespaceDirectiveCheck>());
39 CheckFactories.addCheckFactory(
Daniel Jasperd07c8402013-07-29 08:19:24 +000040 "google-explicit-constructor",
41 new ClangTidyCheckFactory<ExplicitConstructorCheck>());
Alexander Kornienko276fc642014-06-29 22:19:53 +000042 CheckFactories.addCheckFactory(
Benjamin Kramerfeff1342014-07-15 12:48:14 +000043 "google-runtime-operator",
44 new ClangTidyCheckFactory<runtime::OverloadedUnaryAndCheck>());
45 CheckFactories.addCheckFactory(
Benjamin Kramerb1039752014-07-16 10:00:14 +000046 "google-runtime-member-string-references",
47 new ClangTidyCheckFactory<runtime::StringReferenceMemberCheck>());
48 CheckFactories.addCheckFactory(
Alexander Kornienko276fc642014-06-29 22:19:53 +000049 "google-readability-casting",
50 new ClangTidyCheckFactory<readability::AvoidCStyleCastsCheck>());
Benjamin Kramer14d42d92014-07-15 16:47:09 +000051 CheckFactories.addCheckFactory(
52 "google-readability-function",
53 new ClangTidyCheckFactory<readability::NamedParameterCheck>());
Daniel Jasperd07c8402013-07-29 08:19:24 +000054 }
55};
56
57// Register the GoogleTidyModule using this statically initialized variable.
58static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
59 "Adds Google lint checks.");
60
61// This anchor is used to force the linker to link in the generated object file
62// and thus register the GoogleModule.
63volatile int GoogleModuleAnchorSource = 0;
64
65} // namespace tidy
66} // namespace clang