From 5d08bb72d91a1f0873d2286f9f3514cf8607ff7f Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Fri, 20 May 2016 13:42:40 +0000 Subject: [PATCH] [clang-tidy] Switch to a more common way of customizing check behavior. This should have been done this way from the start, however I somehow missed r257177. llvm-svn: 270215 --- .../clang-tidy/ClangTidyDiagnosticConsumer.cpp | 4 ---- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h | 3 --- clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp | 5 +++++ .../clang-tidy/misc/MoveConstructorInitCheck.cpp | 6 ++++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index e9a448eaf86b..d0a7e5f5080d 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -223,10 +223,6 @@ GlobList &ClangTidyContext::getChecksFilter() { return *CheckFilter; } -bool ClangTidyContext::isCheckEnabled(StringRef CheckName) const { - return CheckFilter->contains(CheckName); -} - GlobList &ClangTidyContext::getWarningAsErrorFilter() { assert(WarningAsErrorFilter != nullptr); return *WarningAsErrorFilter; diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h index 8d46a2988ee7..d7e4d2be9aaa 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h @@ -172,9 +172,6 @@ public: /// The \c CurrentFile can be changed using \c setCurrentFile. GlobList &getChecksFilter(); - /// \brief Returns true if the check name is enabled for the \c CurrentFile. - bool isCheckEnabled(StringRef CheckName) const; - /// \brief Returns check filter for the \c CurrentFile which /// selects checks for upgrade to error. GlobList &getWarningAsErrorFilter(); diff --git a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp index 6ba020667b7c..1a0d9c548573 100644 --- a/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp @@ -69,6 +69,11 @@ public: CheckFactories.registerCheck( "cert-err34-c"); } + ClangTidyOptions getModuleOptions() override { + ClangTidyOptions Options; + Options.CheckOptions["cert-oop11-cpp.UseCERTSemantics"] = "1"; + return Options; + } }; } // namespace cert diff --git a/clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp b/clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp index 79973990f0ec..acb6de476973 100644 --- a/clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/MoveConstructorInitCheck.cpp @@ -44,7 +44,7 @@ MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name, : ClangTidyCheck(Name, Context), IncludeStyle(utils::IncludeSorter::parseIncludeStyle( Options.get("IncludeStyle", "llvm"))), - UseCERTSemantics(Context->isCheckEnabled("cert-oop11-cpp")) {} + UseCERTSemantics(Options.get("UseCERTSemantics", 0) != 0) {} void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++11; the functionality currently does not @@ -72,7 +72,7 @@ void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) { // This checker is also used to implement cert-oop11-cpp, but when using that // form of the checker, we do not want to diagnose movable parameters. - if (!UseCERTSemantics) + if (!UseCERTSemantics) { Finder->addMatcher( cxxConstructorDecl( allOf( @@ -89,6 +89,7 @@ void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) { .bind("init-arg"))))))) .bind("ctor-decl"), this); + } } void MoveConstructorInitCheck::check(const MatchFinder::MatchResult &Result) { @@ -176,6 +177,7 @@ void MoveConstructorInitCheck::registerPPCallbacks(CompilerInstance &Compiler) { void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "IncludeStyle", utils::IncludeSorter::toString(IncludeStyle)); + Options.store(Opts, "UseCERTSemantics", UseCERTSemantics ? 1 : 0); } } // namespace misc