diff options
| author | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-11-02 21:14:22 +0000 |
|---|---|---|
| committer | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-11-02 21:14:22 +0000 |
| commit | cb2e749e4611d22e710f5c5084420909312405b3 (patch) | |
| tree | 309df68316c644db168c5d31ed05116c1cfd747d /clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp | |
| parent | fbebe1632aaa0f5cc52a4d902cc80eb9b97efa6a (diff) | |
| download | bcm5719-llvm-cb2e749e4611d22e710f5c5084420909312405b3.tar.gz bcm5719-llvm-cb2e749e4611d22e710f5c5084420909312405b3.zip | |
[clang-tidy] Suppress notes for warnings that were ignored
Fixes PR30565.
Patch by Nikita Kakuev
llvm-svn: 285861
Diffstat (limited to 'clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp')
| -rw-r--r-- | clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index 3b90c557000..a58d32dfbdb 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -250,7 +250,7 @@ StringRef ClangTidyContext::getCheckName(unsigned DiagnosticID) const { ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx) : Context(Ctx), LastErrorRelatesToUserCode(false), - LastErrorPassesLineFilter(false) { + LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) { IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions(); Diags.reset(new DiagnosticsEngine( IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, this, @@ -309,13 +309,20 @@ static bool LineIsMarkedWithNOLINTinMacro(SourceManager &SM, void ClangTidyDiagnosticConsumer::HandleDiagnostic( DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) { + if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note) + return; + if (Info.getLocation().isValid() && DiagLevel != DiagnosticsEngine::Error && DiagLevel != DiagnosticsEngine::Fatal && LineIsMarkedWithNOLINTinMacro(Diags->getSourceManager(), Info.getLocation())) { ++Context.Stats.ErrorsIgnoredNOLINT; + // Ignored a warning, should ignore related notes as well + LastErrorWasIgnored = true; return; } + + LastErrorWasIgnored = false; // Count warnings/errors. DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info); |

