From b5295a95afaa4c8505574396105ef00f57be0e4f Mon Sep 17 00:00:00 2001 From: "Klein, Thorsten (BSH)" Date: Fri, 8 Mar 2019 14:08:45 +0100 Subject: [PATCH] Add check for matching HeaderFilter before emitting Diagnostic --- .../clang-tidy/ClangTidyDiagnosticConsumer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp index 637addf273f35..472790f44689a 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp @@ -449,8 +449,13 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic( FullSourceLoc Loc; if (Info.getLocation().isValid() && Info.hasSourceManager()) Loc = FullSourceLoc(Info.getLocation(), Info.getSourceManager()); - Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(), + + StringRef FileName(Loc.printToString(Loc.getManager())); + if(getHeaderFilter()->match(FileName)) // only emit if FileName is matching + { + Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(), Info.getFixItHints()); + } if (Info.hasSourceManager()) checkFilters(Info.getLocation(), Info.getSourceManager());