[clang-tools-extra] r302536 - [clang-tidy] Allow disabling compatibility check for generated fixes.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue May 9 08:10:27 PDT 2017


Author: alexfh
Date: Tue May  9 10:10:26 2017
New Revision: 302536

URL: http://llvm.org/viewvc/llvm-project?rev=302536&view=rev
Log:
[clang-tidy] Allow disabling compatibility check for generated fixes.

Modified:
    clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
    clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h

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=302536&r1=302535&r2=302536&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Tue May  9 10:10:26 2017
@@ -237,9 +237,11 @@ StringRef ClangTidyContext::getCheckName
   return "";
 }
 
-ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx)
-    : Context(Ctx), LastErrorRelatesToUserCode(false),
-      LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {
+ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
+    ClangTidyContext &Ctx, bool RemoveIncompatibleErrors)
+    : Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
+      LastErrorRelatesToUserCode(false), LastErrorPassesLineFilter(false),
+      LastErrorWasIgnored(false) {
   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
   Diags.reset(new DiagnosticsEngine(
       IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, this,
@@ -611,7 +613,9 @@ void ClangTidyDiagnosticConsumer::finish
   std::sort(Errors.begin(), Errors.end(), LessClangTidyError());
   Errors.erase(std::unique(Errors.begin(), Errors.end(), EqualClangTidyError()),
                Errors.end());
-  removeIncompatibleErrors(Errors);
+
+  if (RemoveIncompatibleErrors)
+    removeIncompatibleErrors(Errors);
 
   for (const ClangTidyError &Error : Errors)
     Context.storeError(Error);

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=302536&r1=302535&r2=302536&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Tue May  9 10:10:26 2017
@@ -223,7 +223,8 @@ private:
 // implementation file.
 class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
 public:
-  ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx);
+  ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx,
+                              bool RemoveIncompatibleErrors = true);
 
   // FIXME: The concept of converting between FixItHints and Replacements is
   // more generic and should be pulled out into a more useful Diagnostics
@@ -249,6 +250,7 @@ private:
   bool passesLineFilter(StringRef FileName, unsigned LineNumber) const;
 
   ClangTidyContext &Context;
+  bool RemoveIncompatibleErrors;
   std::unique_ptr<DiagnosticsEngine> Diags;
   SmallVector<ClangTidyError, 8> Errors;
   std::unique_ptr<llvm::Regex> HeaderFilter;




More information about the cfe-commits mailing list