diff options
author | Nikolai Kosjar <[email protected]> | 2019-07-09 12:42:07 +0200 |
---|---|---|
committer | Nikolai Kosjar <[email protected]> | 2019-07-10 07:56:57 +0000 |
commit | b6346369eb9c4b10ea6ca7735b58cd1c6cf73074 (patch) | |
tree | 9ee617a7470c92c9ec8807418643de2b74dacbc1 /src/plugins/clangtools/clangtoolslogfilereader.cpp | |
parent | 2aa067f28e973df757b65830ba6c278ebc03e6e6 (diff) |
ClangTools: Fix showing diagnostics outside the project root dir
Accept diagnostics from files that are known to the project
(Project::files()) instead of checking whether they are below the
project root directory (Project::projectDirectory()).
Fixes: QTCREATORBUG-22213
Change-Id: I2f96374d6de3f53b1bd42be875dfe44b25a55fb1
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/plugins/clangtools/clangtoolslogfilereader.cpp')
-rw-r--r-- | src/plugins/clangtools/clangtoolslogfilereader.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/plugins/clangtools/clangtoolslogfilereader.cpp b/src/plugins/clangtools/clangtoolslogfilereader.cpp index 63751181ee8..76c38f44bec 100644 --- a/src/plugins/clangtools/clangtoolslogfilereader.cpp +++ b/src/plugins/clangtools/clangtoolslogfilereader.cpp @@ -122,7 +122,7 @@ static ExplainingStep buildFixIt(const CXDiagnostic cxDiagnostic, unsigned index } static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic, - const Utils::FilePath &projectRootDir, + const QSet<Utils::FilePath> &projectFiles, const QString &nativeFilePath) { Diagnostic diagnostic; @@ -136,7 +136,7 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic, diagnostic.location = diagLocationFromSourceLocation(cxLocation); const auto diagnosticFilePath = Utils::FilePath::fromString(diagnostic.location.filePath); - if (!diagnosticFilePath.isChildOf(projectRootDir)) + if (!projectFiles.contains(diagnosticFilePath)) return diagnostic; // TODO: Introduce CppTools::ProjectFile::isGenerated to filter these out properly @@ -183,7 +183,7 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic, } static QList<Diagnostic> readSerializedDiagnostics_helper(const QString &filePath, - const Utils::FilePath &projectRootDir, + const QSet<Utils::FilePath> &projectFiles, const QString &logFilePath) { QList<Diagnostic> list; @@ -206,7 +206,7 @@ static QList<Diagnostic> readSerializedDiagnostics_helper(const QString &filePat Utils::ExecuteOnDestruction cleanUpDiagnostic([&]() { clang_disposeDiagnostic(cxDiagnostic); }); - const Diagnostic diagnostic = buildDiagnostic(cxDiagnostic, projectRootDir, nativeFilePath); + const Diagnostic diagnostic = buildDiagnostic(cxDiagnostic, projectFiles, nativeFilePath); if (!diagnostic.isValid()) continue; @@ -232,14 +232,14 @@ static bool checkFilePath(const QString &filePath, QString *errorMessage) } QList<Diagnostic> readSerializedDiagnostics(const QString &filePath, - const Utils::FilePath &projectRootDir, + const QSet<Utils::FilePath> &projectFiles, const QString &logFilePath, QString *errorMessage) { if (!checkFilePath(logFilePath, errorMessage)) return QList<Diagnostic>(); - return readSerializedDiagnostics_helper(filePath, projectRootDir, logFilePath); + return readSerializedDiagnostics_helper(filePath, projectFiles, logFilePath); } } // namespace Internal |