forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -165,24 +165,23 @@ void ClangToolRunWorker::start()
|
|||||||
.arg(toolName, projectFile.toUserOutput(), m_diagnosticConfig.displayName()),
|
.arg(toolName, projectFile.toUserOutput(), m_diagnosticConfig.displayName()),
|
||||||
Utils::NormalMessageFormat);
|
Utils::NormalMessageFormat);
|
||||||
|
|
||||||
// Collect files
|
const ClangToolType tool = m_tool == ClangTidyTool::instance() ? ClangToolType::Tidy
|
||||||
const auto [includeDir, clangVersion]
|
: ClangToolType::Clazy;
|
||||||
= getClangIncludeDirAndVersion(runControl()->commandLine().executable());
|
const FilePath executable = toolExecutable(tool);
|
||||||
|
const auto [includeDir, clangVersion] = getClangIncludeDirAndVersion(executable);
|
||||||
|
|
||||||
|
// Collect files
|
||||||
AnalyzeUnits unitsToProcess;
|
AnalyzeUnits unitsToProcess;
|
||||||
for (const FileInfo &fileInfo : m_fileInfos)
|
for (const FileInfo &fileInfo : m_fileInfos)
|
||||||
unitsToProcess.append({fileInfo, includeDir, clangVersion});
|
unitsToProcess.append({fileInfo, includeDir, clangVersion});
|
||||||
|
|
||||||
qCDebug(LOG) << Q_FUNC_INFO << runControl()->commandLine().executable()
|
qCDebug(LOG) << Q_FUNC_INFO << executable << includeDir << clangVersion;
|
||||||
<< includeDir << clangVersion;
|
|
||||||
qCDebug(LOG) << "Files to process:" << unitsToProcess;
|
qCDebug(LOG) << "Files to process:" << unitsToProcess;
|
||||||
qCDebug(LOG) << "Environment:" << m_environment;
|
qCDebug(LOG) << "Environment:" << m_environment;
|
||||||
|
|
||||||
m_filesAnalyzed.clear();
|
m_filesAnalyzed.clear();
|
||||||
m_filesNotAnalyzed.clear();
|
m_filesNotAnalyzed.clear();
|
||||||
|
|
||||||
const ClangToolType tool = m_tool == ClangTidyTool::instance() ? ClangToolType::Tidy
|
|
||||||
: ClangToolType::Clazy;
|
|
||||||
using namespace Tasking;
|
using namespace Tasking;
|
||||||
QList<TaskItem> tasks{ParallelLimit(qMax(1, m_runSettings.parallelJobs()))};
|
QList<TaskItem> tasks{ParallelLimit(qMax(1, m_runSettings.parallelJobs()))};
|
||||||
for (const AnalyzeUnit &unit : std::as_const(unitsToProcess)) {
|
for (const AnalyzeUnit &unit : std::as_const(unitsToProcess)) {
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ static QPair<FilePath, QString> clangIncludeDirAndVersion(const FilePath &clangT
|
|||||||
|
|
||||||
QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolPath)
|
QPair<FilePath, QString> getClangIncludeDirAndVersion(const FilePath &clangToolPath)
|
||||||
{
|
{
|
||||||
|
QTC_CHECK(!clangToolPath.isEmpty());
|
||||||
static QMap<FilePath, QPair<FilePath, QString>> cache;
|
static QMap<FilePath, QPair<FilePath, QString>> cache;
|
||||||
auto it = cache.find(clangToolPath);
|
auto it = cache.find(clangToolPath);
|
||||||
if (it == cache.end())
|
if (it == cache.end())
|
||||||
|
|||||||
Reference in New Issue
Block a user