blob: 43eacfc39e2cb6be439dc558627ec535b31695a8 [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"
Daniel Jasperd07c8402013-07-29 08:19:24 +000019
20using namespace clang::ast_matchers;
21
22namespace clang {
23namespace tidy {
24
Daniel Jasperd07c8402013-07-29 08:19:24 +000025class GoogleModule : public ClangTidyModule {
26public:
Alexander Kornienko21f3b772014-03-05 13:01:24 +000027 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Daniel Jasperd07c8402013-07-29 08:19:24 +000028 CheckFactories.addCheckFactory(
Benjamin Kramer47c4d102014-07-15 09:50:32 +000029 "google-build-explicit-make-pair",
30 new ClangTidyCheckFactory<build::ExplicitMakePairCheck>());
31 CheckFactories.addCheckFactory(
Daniel Jasperd07c8402013-07-29 08:19:24 +000032 "google-explicit-constructor",
33 new ClangTidyCheckFactory<ExplicitConstructorCheck>());
Alexander Kornienko276fc642014-06-29 22:19:53 +000034 CheckFactories.addCheckFactory(
Benjamin Kramerfeff1342014-07-15 12:48:14 +000035 "google-runtime-operator",
36 new ClangTidyCheckFactory<runtime::OverloadedUnaryAndCheck>());
37 CheckFactories.addCheckFactory(
Benjamin Kramerb1039752014-07-16 10:00:14 +000038 "google-runtime-member-string-references",
39 new ClangTidyCheckFactory<runtime::StringReferenceMemberCheck>());
40 CheckFactories.addCheckFactory(
Alexander Kornienko276fc642014-06-29 22:19:53 +000041 "google-readability-casting",
42 new ClangTidyCheckFactory<readability::AvoidCStyleCastsCheck>());
Benjamin Kramer14d42d92014-07-15 16:47:09 +000043 CheckFactories.addCheckFactory(
44 "google-readability-function",
45 new ClangTidyCheckFactory<readability::NamedParameterCheck>());
Daniel Jasperd07c8402013-07-29 08:19:24 +000046 }
47};
48
49// Register the GoogleTidyModule using this statically initialized variable.
50static ClangTidyModuleRegistry::Add<GoogleModule> X("google-module",
51 "Adds Google lint checks.");
52
53// This anchor is used to force the linker to link in the generated object file
54// and thus register the GoogleModule.
55volatile int GoogleModuleAnchorSource = 0;
56
57} // namespace tidy
58} // namespace clang