blob: 9f482b171b7b6c8f85d279ace3f1959c13416ac3 [file] [log] [blame]
Alexander Kornienkofc650862015-08-14 13:17:11 +00001//===--- ModernizeTidyModule.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"
Alexander Kornienko04970842015-08-19 09:11:46 +000013#include "LoopConvertCheck.h"
Alexander Kornienkofc650862015-08-14 13:17:11 +000014#include "PassByValueCheck.h"
Angel Garcia Gomez5b9d33a2015-08-21 15:08:51 +000015#include "UseAutoCheck.h"
Alexander Kornienko1b7bf7a2015-08-19 22:21:37 +000016#include "UseNullptrCheck.h"
Alexander Kornienkofc650862015-08-14 13:17:11 +000017
18using namespace clang::ast_matchers;
19
20namespace clang {
21namespace tidy {
22namespace modernize {
23
24class ModernizeModule : public ClangTidyModule {
25public:
26 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Alexander Kornienko04970842015-08-19 09:11:46 +000027 CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");
Alexander Kornienkofc650862015-08-14 13:17:11 +000028 CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
Angel Garcia Gomez5b9d33a2015-08-21 15:08:51 +000029 CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
Alexander Kornienko1b7bf7a2015-08-19 22:21:37 +000030 CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
Alexander Kornienkofc650862015-08-14 13:17:11 +000031 }
32
33 ClangTidyOptions getModuleOptions() override {
34 ClangTidyOptions Options;
35 auto &Opts = Options.CheckOptions;
Alexander Kornienko04970842015-08-19 09:11:46 +000036 Opts["modernize-loop-convert.MinConfidence"] = "reasonable";
Alexander Kornienkofc650862015-08-14 13:17:11 +000037 Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google".
Alexander Kornienko1b7bf7a2015-08-19 22:21:37 +000038
39 // Comma-separated list of macros that behave like NULL.
40 Opts["modernize-use-nullptr.NullMacros"] = "NULL";
Alexander Kornienkofc650862015-08-14 13:17:11 +000041 return Options;
42 }
43};
44
45// Register the ModernizeTidyModule using this statically initialized variable.
46static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module",
47 "Add modernize checks.");
48
49} // namespace modernize
50
51// This anchor is used to force the linker to link in the generated object file
52// and thus register the ModernizeModule.
53volatile int ModernizeModuleAnchorSource = 0;
54
55} // namespace tidy
56} // namespace clang