[clang-tools-extra] r270215 - [clang-tidy] Switch to a more common way of customizing check behavior.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 06:42:42 PDT 2016


Author: alexfh
Date: Fri May 20 08:42:40 2016
New Revision: 270215

URL: http://llvm.org/viewvc/llvm-project?rev=270215&view=rev
Log:
[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.

Modified:
    clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
    clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
    clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
    clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=270215&r1=270214&r2=270215&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Fri May 20 08:42:40 2016
@@ -223,10 +223,6 @@ GlobList &ClangTidyContext::getChecksFil
   return *CheckFilter;
 }
 
-bool ClangTidyContext::isCheckEnabled(StringRef CheckName) const {
-  return CheckFilter->contains(CheckName);
-}
-
 GlobList &ClangTidyContext::getWarningAsErrorFilter() {
   assert(WarningAsErrorFilter != nullptr);
   return *WarningAsErrorFilter;

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=270215&r1=270214&r2=270215&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Fri May 20 08:42:40 2016
@@ -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();

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=270215&r1=270214&r2=270215&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Fri May 20 08:42:40 2016
@@ -69,6 +69,11 @@ public:
     CheckFactories.registerCheck<StrToNumCheck>(
         "cert-err34-c");
   }
+  ClangTidyOptions getModuleOptions() override {
+    ClangTidyOptions Options;
+    Options.CheckOptions["cert-oop11-cpp.UseCERTSemantics"] = "1";
+    return Options;
+  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=270215&r1=270214&r2=270215&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Fri May 20 08:42:40 2016
@@ -44,7 +44,7 @@ MoveConstructorInitCheck::MoveConstructo
     : 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::registerM
 
   // 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::registerM
                             .bind("init-arg")))))))
             .bind("ctor-decl"),
         this);
+  }
 }
 
 void MoveConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
@@ -176,6 +177,7 @@ void MoveConstructorInitCheck::registerP
 void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "IncludeStyle",
                 utils::IncludeSorter::toString(IncludeStyle));
+  Options.store(Opts, "UseCERTSemantics", UseCERTSemantics ? 1 : 0);
 }
 
 } // namespace misc




More information about the cfe-commits mailing list