ClangTools: Remove "in file included from" trace for header diagnostics

...as this does not add much value but rather noise.

Change-Id: I0bb8807c3f4df4114ea135bea74cde3fd21ab090
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-02-06 09:34:00 +01:00
parent 7d64c9e3ec
commit a60cd0ba30

View File

@@ -25,6 +25,8 @@
#include "clangtoolslogfilereader.h" #include "clangtoolslogfilereader.h"
#include <cpptools/cppprojectfile.h>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QObject> #include <QObject>
@@ -147,6 +149,10 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic,
clang_disposeDiagnosticSet(cxChildDiagnostics); 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) { for (unsigned i = 0; i < clang_getNumDiagnosticsInSet(cxChildDiagnostics); ++i) {
CXDiagnostic cxDiagnostic = clang_getDiagnosticInSet(cxChildDiagnostics, i); CXDiagnostic cxDiagnostic = clang_getDiagnosticInSet(cxChildDiagnostics, i);
Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() { Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() {
@@ -156,6 +162,9 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic,
if (diagnosticStep.isValid()) if (diagnosticStep.isValid())
continue; continue;
if (isHeaderFile && diagnosticStep.message.contains("in file included from"))
continue;
if (isInvalidDiagnosticLocation(diagnostic, diagnosticStep, nativeFilePath)) if (isInvalidDiagnosticLocation(diagnostic, diagnosticStep, nativeFilePath))
return diagnostic; return diagnostic;