diff --git a/src/plugins/clangtools/clangtoolslogfilereader.cpp b/src/plugins/clangtools/clangtoolslogfilereader.cpp index d1e98fac87b..d2213d3304e 100644 --- a/src/plugins/clangtools/clangtoolslogfilereader.cpp +++ b/src/plugins/clangtools/clangtoolslogfilereader.cpp @@ -25,6 +25,8 @@ #include "clangtoolslogfilereader.h" +#include + #include #include #include @@ -147,6 +149,10 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic, clang_disposeDiagnosticSet(cxChildDiagnostics); }); + using CppTools::ProjectFile; + const bool isHeaderFile = ProjectFile::isHeader( + ProjectFile::classify(diagnostic.location.filePath)); + for (unsigned i = 0; i < clang_getNumDiagnosticsInSet(cxChildDiagnostics); ++i) { CXDiagnostic cxDiagnostic = clang_getDiagnosticInSet(cxChildDiagnostics, i); Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() { @@ -156,6 +162,9 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic, if (diagnosticStep.isValid()) continue; + if (isHeaderFile && diagnosticStep.message.contains("in file included from")) + continue; + if (isInvalidDiagnosticLocation(diagnostic, diagnosticStep, nativeFilePath)) return diagnostic;