summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy
diff options
context:
space:
mode:
authorMalcolm Parsons <malcolm.parsons@gmail.com>2016-11-02 21:14:22 +0000
committerMalcolm Parsons <malcolm.parsons@gmail.com>2016-11-02 21:14:22 +0000
commitcb2e749e4611d22e710f5c5084420909312405b3 (patch)
tree309df68316c644db168c5d31ed05116c1cfd747d /clang-tools-extra/clang-tidy
parentfbebe1632aaa0f5cc52a4d902cc80eb9b97efa6a (diff)
downloadbcm5719-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')
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp9
-rw-r--r--clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h1
2 files changed, 9 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);
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 9f83aac60ba..374331c5ef6 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -286,6 +286,7 @@ private:
std::unique_ptr<llvm::Regex> HeaderFilter;
bool LastErrorRelatesToUserCode;
bool LastErrorPassesLineFilter;
+ bool LastErrorWasIgnored;
};
} // end namespace tidy
OpenPOWER on IntegriCloud