blob: 568abbdac4be9e8428256118a018c14e288b7131 [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 Gomez19016712015-08-25 13:03:43 +000015#include "ReplaceAutoPtrCheck.h"
Alexander Kornienko0ed6c472015-08-31 13:17:43 +000016#include "ShrinkToFitCheck.h"
Angel Garcia Gomez5b9d33a2015-08-21 15:08:51 +000017#include "UseAutoCheck.h"
Alexander Kornienko1b7bf7a2015-08-19 22:21:37 +000018#include "UseNullptrCheck.h"
Alexander Kornienko0ed6c472015-08-31 13:17:43 +000019#include "UseOverrideCheck.h"
Alexander Kornienkofc650862015-08-14 13:17:11 +000020
21using namespace clang::ast_matchers;
22
23namespace clang {
24namespace tidy {
25namespace modernize {
26
27class ModernizeModule : public ClangTidyModule {
28public:
29 void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
Alexander Kornienko04970842015-08-19 09:11:46 +000030 CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");
Alexander Kornienkofc650862015-08-14 13:17:11 +000031 CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
Angel Garcia Gomez19016712015-08-25 13:03:43 +000032 CheckFactories.registerCheck<ReplaceAutoPtrCheck>(
33 "modernize-replace-auto-ptr");
Alexander Kornienko0ed6c472015-08-31 13:17:43 +000034 CheckFactories.registerCheck<ShrinkToFitCheck>("modernize-shrink-to-fit");
Angel Garcia Gomez5b9d33a2015-08-21 15:08:51 +000035 CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
Alexander Kornienko1b7bf7a2015-08-19 22:21:37 +000036 CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
Alexander Kornienko0ed6c472015-08-31 13:17:43 +000037 CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override");
Alexander Kornienkofc650862015-08-14 13:17:11 +000038 }
39
40 ClangTidyOptions getModuleOptions() override {
41 ClangTidyOptions Options;
42 auto &Opts = Options.CheckOptions;
Alexander Kornienko04970842015-08-19 09:11:46 +000043 Opts["modernize-loop-convert.MinConfidence"] = "reasonable";
Angel Garcia Gomez8535c6c2015-09-24 17:02:19 +000044 Opts["modernize-loop-convert.NamingStyle"] = "CamelCase";
Alexander Kornienkofc650862015-08-14 13:17:11 +000045 Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google".
Angel Garcia Gomez19016712015-08-25 13:03:43 +000046 Opts["modernize-replace-auto-ptr.IncludeStyle"] = "llvm"; // Also: "google".
Alexander Kornienko1b7bf7a2015-08-19 22:21:37 +000047
48 // Comma-separated list of macros that behave like NULL.
49 Opts["modernize-use-nullptr.NullMacros"] = "NULL";
Alexander Kornienkofc650862015-08-14 13:17:11 +000050 return Options;
51 }
52};
53
54// Register the ModernizeTidyModule using this statically initialized variable.
55static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module",
56 "Add modernize checks.");
57
58} // namespace modernize
59
60// This anchor is used to force the linker to link in the generated object file
61// and thus register the ModernizeModule.
62volatile int ModernizeModuleAnchorSource = 0;
63
64} // namespace tidy
65} // namespace clang