From 16df6164b0ecf95bf725e4dd5fd75e93a1836d19 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 24 Aug 2021 14:06:19 +0200 Subject: [PATCH] MSVC: Consider build environment when calculating header paths Fixes: QTCREATORBUG-25816 Change-Id: Id6274d2bec4ed3db07729f1d88a5a9ad82c8d98d Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/msvctoolchain.cpp | 18 ++++++++++-------- src/plugins/projectexplorer/msvctoolchain.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index f441633741d..3467df0af1e 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -1125,13 +1125,15 @@ ToolChain::BuiltInHeaderPathsRunner MsvcToolChain::createBuiltInHeaderPathsRunne return [this, fullEnv](const QStringList &, const QString &, const QString &) { QMutexLocker locker(&m_headerPathsMutex); - if (m_headerPaths.isEmpty()) { - m_headerPaths = transform(fullEnv.pathListValue("INCLUDE"), - [](const FilePath &p) { - return HeaderPath(p.toString(), HeaderPathType::BuiltIn); - }); - } - return m_headerPaths; + const auto envList = fullEnv.toStringList(); + const auto it = m_headerPathsPerEnv.constFind(envList); + if (it != m_headerPathsPerEnv.cend()) + return *it; + const auto mapper = [](const FilePath &p) { // TODO: Define functions for this. + return HeaderPath(p.toString(), HeaderPathType::BuiltIn); + }; + return *m_headerPathsPerEnv.insert(envList, + transform(fullEnv.pathListValue("INCLUDE"), mapper)); }; } @@ -1787,7 +1789,7 @@ ClangClToolChain::BuiltInHeaderPathsRunner ClangClToolChain::createBuiltInHeader { { QMutexLocker locker(&m_headerPathsMutex); - m_headerPaths.clear(); + m_headerPathsPerEnv.clear(); } return MsvcToolChain::createBuiltInHeaderPathsRunner(env); diff --git a/src/plugins/projectexplorer/msvctoolchain.h b/src/plugins/projectexplorer/msvctoolchain.h index a13afe753d2..2e42a163da5 100644 --- a/src/plugins/projectexplorer/msvctoolchain.h +++ b/src/plugins/projectexplorer/msvctoolchain.h @@ -140,7 +140,7 @@ protected: protected: mutable QMutex m_headerPathsMutex; - mutable HeaderPaths m_headerPaths; + mutable QHash m_headerPathsPerEnv; private: void updateEnvironmentModifications(Utils::EnvironmentItems modifications);