2015-08-14 21:17:11 +08:00
|
|
|
//===--- ModernizeTidyModule.cpp - clang-tidy -----------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "../ClangTidy.h"
|
|
|
|
#include "../ClangTidyModule.h"
|
|
|
|
#include "../ClangTidyModuleRegistry.h"
|
2015-08-19 17:11:46 +08:00
|
|
|
#include "LoopConvertCheck.h"
|
2015-08-14 21:17:11 +08:00
|
|
|
#include "PassByValueCheck.h"
|
2015-08-21 23:08:51 +08:00
|
|
|
#include "UseAutoCheck.h"
|
2015-08-20 06:21:37 +08:00
|
|
|
#include "UseNullptrCheck.h"
|
2015-08-14 21:17:11 +08:00
|
|
|
|
|
|
|
using namespace clang::ast_matchers;
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
namespace tidy {
|
|
|
|
namespace modernize {
|
|
|
|
|
|
|
|
class ModernizeModule : public ClangTidyModule {
|
|
|
|
public:
|
|
|
|
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
|
2015-08-19 17:11:46 +08:00
|
|
|
CheckFactories.registerCheck<LoopConvertCheck>("modernize-loop-convert");
|
2015-08-14 21:17:11 +08:00
|
|
|
CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
|
2015-08-21 23:08:51 +08:00
|
|
|
CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
|
2015-08-20 06:21:37 +08:00
|
|
|
CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
|
2015-08-14 21:17:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ClangTidyOptions getModuleOptions() override {
|
|
|
|
ClangTidyOptions Options;
|
|
|
|
auto &Opts = Options.CheckOptions;
|
2015-08-19 17:11:46 +08:00
|
|
|
Opts["modernize-loop-convert.MinConfidence"] = "reasonable";
|
2015-08-14 21:17:11 +08:00
|
|
|
Opts["modernize-pass-by-value.IncludeStyle"] = "llvm"; // Also: "google".
|
2015-08-20 06:21:37 +08:00
|
|
|
|
|
|
|
// Comma-separated list of macros that behave like NULL.
|
|
|
|
Opts["modernize-use-nullptr.NullMacros"] = "NULL";
|
2015-08-14 21:17:11 +08:00
|
|
|
return Options;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Register the ModernizeTidyModule using this statically initialized variable.
|
|
|
|
static ClangTidyModuleRegistry::Add<ModernizeModule> X("modernize-module",
|
|
|
|
"Add modernize checks.");
|
|
|
|
|
|
|
|
} // namespace modernize
|
|
|
|
|
|
|
|
// This anchor is used to force the linker to link in the generated object file
|
|
|
|
// and thus register the ModernizeModule.
|
|
|
|
volatile int ModernizeModuleAnchorSource = 0;
|
|
|
|
|
|
|
|
} // namespace tidy
|
|
|
|
} // namespace clang
|