diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-03-13 15:02:03 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-03-13 15:27:11 +0000 |
commit | d6125816678fb1b84b02456bb3f6602740a2499a (patch) | |
tree | b793dbe7fbb8798ac994f69a66a953ae1d4e18d0 | |
parent | 287783a7762547b1c5361455ac30c268941fe7a1 (diff) |
ClangTools: Fix include path retrieval
This seems to have silently broken ages ago, perhaps when run workers
were introduced: The clang tools' run controls no longer hold the
executable, so we passed an empty file path to the function that was
supposed to retrieve the include path, which in turn gave us compile-
time values as a fallback.
Change-Id: Ie275dab93e4a4ed551c3c8fcd604cd37a3b7bd0e
Reviewed-by: hjk <hjk@qt.io>
-rw-r--r-- | src/plugins/clangtools/clangtoolruncontrol.cpp | 13 | ||||
-rw-r--r-- | src/plugins/clangtools/executableinfo.cpp | 1 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/plugins/clangtools/clangtoolruncontrol.cpp b/src/plugins/clangtools/clangtoolruncontrol.cpp index c684774ef8..7881b53916 100644 --- a/src/plugins/clangtools/clangtoolruncontrol.cpp +++ b/src/plugins/clangtools/clangtoolruncontrol.cpp @@ -165,24 +165,23 @@ void ClangToolRunWorker::start() .arg(toolName, projectFile.toUserOutput(), m_diagnosticConfig.displayName()), Utils::NormalMessageFormat); - // Collect files - const auto [includeDir, clangVersion] - = getClangIncludeDirAndVersion(runControl()->commandLine().executable()); + const ClangToolType tool = m_tool == ClangTidyTool::instance() ? ClangToolType::Tidy + : ClangToolType::Clazy; + const FilePath executable = toolExecutable(tool); + const auto [includeDir, clangVersion] = getClangIncludeDirAndVersion(executable); + // Collect files AnalyzeUnits unitsToProcess; for (const FileInfo &fileInfo : m_fileInfos) unitsToProcess.append({fileInfo, includeDir, clangVersion}); - qCDebug(LOG) << Q_FUNC_INFO << runControl()->commandLine().executable() - << includeDir << clangVersion; + qCDebug(LOG) << Q_FUNC_INFO << executable << includeDir << clangVersion; qCDebug(LOG) << "Files to process:" << unitsToProcess; qCDebug(LOG) << "Environment:" << m_environment; m_filesAnalyzed.clear(); m_filesNotAnalyzed.clear(); - const ClangToolType tool = m_tool == ClangTidyTool::instance() ? ClangToolType::Tidy - : ClangToolType::Clazy; using namespace Tasking; QList<TaskItem> tasks{ParallelLimit(qMax(1, m_runSettings.parallelJobs()))}; for (const AnalyzeUnit &unit : std::as_const(unitsToProcess)) { diff --git a/src/plugins/clangtools/executableinfo.cpp b/src/plugins/clangtools/executableinfo.cpp index 643b7afe00..1e280a6889 100644 --- a/src/plugins/clangtools/executableinfo.cpp +++ b/src/plugins/clangtools/executableinfo.cpp @@ -225,6 +225,7 @@ static QPair<FilePath, QString> clangIncludeDirAndVersion(const FilePath &clangT QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolPath) { + QTC_CHECK(!clangToolPath.isEmpty()); static QMap<FilePath, QPair<FilePath, QString>> cache; auto it = cache.find(clangToolPath); if (it == cache.end()) |