forked from qt-creator/qt-creator
ProjectExplorer: Consolidate macro and header path cache handling
All except Nim and the test tool chain were referencing the cache, so move it to the base. This removes also toolChainUpdated() overloads, including the MsvcToolChain one that missed to call the base implementation and the ClangClToolChain one that worked around that. Change-Id: I8a99734aa3c697c635809a3648673a10ca14a2d8 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -223,9 +223,7 @@ static QString buildDisplayName(Abi::Architecture arch, Core::Id language,
|
||||
// IarToolChain
|
||||
|
||||
IarToolChain::IarToolChain(Detection d) :
|
||||
ToolChain(Constants::IAREW_TOOLCHAIN_TYPEID, d),
|
||||
m_predefinedMacrosCache(std::make_shared<Cache<MacroInspectionReport, 64>>()),
|
||||
m_headerPathsCache(std::make_shared<HeaderPathsCache>())
|
||||
ToolChain(Constants::IAREW_TOOLCHAIN_TYPEID, d)
|
||||
{ }
|
||||
|
||||
IarToolChain::IarToolChain(Core::Id language, Detection d) :
|
||||
@@ -265,9 +263,11 @@ ToolChain::MacroInspectionRunner IarToolChain::createMacroInspectionRunner() con
|
||||
const Utils::FileName compilerCommand = m_compilerCommand;
|
||||
const Core::Id lang = language();
|
||||
|
||||
MacrosCache macrosCache = m_predefinedMacrosCache;
|
||||
MacrosCache macrosCache = predefinedMacrosCache();
|
||||
|
||||
return [env, compilerCommand, macrosCache, lang]
|
||||
return [env, compilerCommand,
|
||||
macrosCache,
|
||||
lang]
|
||||
(const QStringList &flags) {
|
||||
Q_UNUSED(flags)
|
||||
|
||||
@@ -303,16 +303,16 @@ ToolChain::BuiltInHeaderPathsRunner IarToolChain::createBuiltInHeaderPathsRunner
|
||||
const Utils::FileName compilerCommand = m_compilerCommand;
|
||||
const Core::Id languageId = language();
|
||||
|
||||
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
||||
HeaderPathsCache headerPaths = headerPathsCache();
|
||||
|
||||
return [env, compilerCommand, headerPathsCache, languageId](const QStringList &flags,
|
||||
return [env, compilerCommand, headerPaths, languageId](const QStringList &flags,
|
||||
const QString &fileName,
|
||||
const QString &) {
|
||||
Q_UNUSED(flags)
|
||||
Q_UNUSED(fileName)
|
||||
|
||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, languageId, env.toStringList());
|
||||
headerPathsCache->insert({}, paths);
|
||||
headerPaths->insert({}, paths);
|
||||
|
||||
return paths;
|
||||
};
|
||||
@@ -394,13 +394,6 @@ ToolChain *IarToolChain::clone() const
|
||||
return new IarToolChain(*this);
|
||||
}
|
||||
|
||||
void IarToolChain::toolChainUpdated()
|
||||
{
|
||||
m_predefinedMacrosCache->invalidate();
|
||||
m_headerPathsCache->invalidate();
|
||||
ToolChain::toolChainUpdated();
|
||||
}
|
||||
|
||||
// IarToolChainFactory
|
||||
|
||||
IarToolChainFactory::IarToolChainFactory()
|
||||
@@ -538,7 +531,7 @@ QList<ToolChain *> IarToolChainFactory::autoDetectToolchain(
|
||||
tc->setDisplayName(buildDisplayName(abi.architecture(), language, candidate.second));
|
||||
|
||||
const auto languageVersion = ToolChain::languageVersion(language, macros);
|
||||
tc->m_predefinedMacrosCache->insert({}, {macros, languageVersion});
|
||||
tc->predefinedMacrosCache()->insert({}, {macros, languageVersion});
|
||||
return {tc};
|
||||
}
|
||||
|
||||
@@ -580,7 +573,7 @@ void IarToolChainConfigWidget::applyImpl()
|
||||
return;
|
||||
|
||||
const auto languageVersion = ToolChain::languageVersion(tc->language(), m_macros);
|
||||
tc->m_predefinedMacrosCache->insert({}, {m_macros, languageVersion});
|
||||
tc->predefinedMacrosCache()->insert({}, {m_macros, languageVersion});
|
||||
|
||||
setFromToolchain();
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchaincache.h>
|
||||
#include <projectexplorer/toolchainconfigwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -86,8 +85,6 @@ public:
|
||||
|
||||
ToolChain *clone() const final;
|
||||
|
||||
void toolChainUpdated() final;
|
||||
|
||||
protected:
|
||||
IarToolChain(const IarToolChain &tc) = default;
|
||||
|
||||
@@ -98,13 +95,6 @@ private:
|
||||
ProjectExplorer::Abi m_targetAbi;
|
||||
Utils::FileName m_compilerCommand;
|
||||
|
||||
using MacrosCache = std::shared_ptr<ProjectExplorer::Cache<MacroInspectionReport, 64>>;
|
||||
mutable MacrosCache m_predefinedMacrosCache;
|
||||
|
||||
using HeaderPathsCache = ProjectExplorer::Cache<ProjectExplorer::HeaderPaths>;
|
||||
using HeaderPathsCachePtr = std::shared_ptr<HeaderPathsCache>;
|
||||
mutable HeaderPathsCachePtr m_headerPathsCache;
|
||||
|
||||
friend class IarToolChainFactory;
|
||||
friend class IarToolChainConfigWidget;
|
||||
};
|
||||
|
@@ -240,9 +240,7 @@ static QString buildDisplayName(Abi::Architecture arch, Core::Id language,
|
||||
// KeilToolchain
|
||||
|
||||
KeilToolchain::KeilToolchain(Detection d) :
|
||||
ToolChain(Constants::KEIL_TOOLCHAIN_TYPEID, d),
|
||||
m_predefinedMacrosCache(std::make_shared<Cache<MacroInspectionReport, 64>>()),
|
||||
m_headerPathsCache(std::make_shared<HeaderPathsCache>())
|
||||
ToolChain(Constants::KEIL_TOOLCHAIN_TYPEID, d)
|
||||
{ }
|
||||
|
||||
KeilToolchain::KeilToolchain(Core::Id language, Detection d) :
|
||||
@@ -282,7 +280,7 @@ ToolChain::MacroInspectionRunner KeilToolchain::createMacroInspectionRunner() co
|
||||
const Utils::FileName compilerCommand = m_compilerCommand;
|
||||
const Core::Id lang = language();
|
||||
|
||||
MacrosCache macroCache = m_predefinedMacrosCache;
|
||||
MacrosCache macroCache = predefinedMacrosCache();
|
||||
|
||||
return [env, compilerCommand, macroCache, lang]
|
||||
(const QStringList &flags) {
|
||||
@@ -316,15 +314,15 @@ ToolChain::BuiltInHeaderPathsRunner KeilToolchain::createBuiltInHeaderPathsRunne
|
||||
{
|
||||
const Utils::FileName compilerCommand = m_compilerCommand;
|
||||
|
||||
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
||||
HeaderPathsCache headerPaths = headerPathsCache();
|
||||
|
||||
return [compilerCommand,
|
||||
headerPathsCache](const QStringList &flags, const QString &fileName, const QString &) {
|
||||
headerPaths](const QStringList &flags, const QString &fileName, const QString &) {
|
||||
Q_UNUSED(flags)
|
||||
Q_UNUSED(fileName)
|
||||
|
||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand);
|
||||
headerPathsCache->insert({}, paths);
|
||||
headerPaths->insert({}, paths);
|
||||
|
||||
return paths;
|
||||
};
|
||||
@@ -406,13 +404,6 @@ ToolChain *KeilToolchain::clone() const
|
||||
return new KeilToolchain(*this);
|
||||
}
|
||||
|
||||
void KeilToolchain::toolChainUpdated()
|
||||
{
|
||||
m_predefinedMacrosCache->invalidate();
|
||||
m_headerPathsCache->invalidate();
|
||||
ToolChain::toolChainUpdated();
|
||||
}
|
||||
|
||||
// KeilToolchainFactory
|
||||
|
||||
KeilToolchainFactory::KeilToolchainFactory()
|
||||
@@ -544,7 +535,7 @@ QList<ToolChain *> KeilToolchainFactory::autoDetectToolchain(
|
||||
tc->setDisplayName(buildDisplayName(abi.architecture(), language, candidate.second));
|
||||
|
||||
const auto languageVersion = ToolChain::languageVersion(language, macros);
|
||||
tc->m_predefinedMacrosCache->insert({}, {macros, languageVersion});
|
||||
tc->predefinedMacrosCache()->insert({}, {macros, languageVersion});
|
||||
return {tc};
|
||||
}
|
||||
|
||||
@@ -586,7 +577,7 @@ void KeilToolchainConfigWidget::applyImpl()
|
||||
return;
|
||||
|
||||
const auto languageVersion = ToolChain::languageVersion(tc->language(), m_macros);
|
||||
tc->m_predefinedMacrosCache->insert({}, {m_macros, languageVersion});
|
||||
tc->predefinedMacrosCache()->insert({}, {m_macros, languageVersion});
|
||||
|
||||
setFromToolchain();
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchaincache.h>
|
||||
#include <projectexplorer/toolchainconfigwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -86,8 +85,6 @@ public:
|
||||
|
||||
ToolChain *clone() const final;
|
||||
|
||||
void toolChainUpdated() final;
|
||||
|
||||
protected:
|
||||
KeilToolchain(const KeilToolchain &tc) = default;
|
||||
|
||||
@@ -98,13 +95,6 @@ private:
|
||||
ProjectExplorer::Abi m_targetAbi;
|
||||
Utils::FileName m_compilerCommand;
|
||||
|
||||
using MacrosCache = std::shared_ptr<ProjectExplorer::Cache<MacroInspectionReport, 64>>;
|
||||
mutable MacrosCache m_predefinedMacrosCache;
|
||||
|
||||
using HeaderPathsCache = ProjectExplorer::Cache<ProjectExplorer::HeaderPaths>;
|
||||
using HeaderPathsCachePtr = std::shared_ptr<HeaderPathsCache>;
|
||||
mutable HeaderPathsCachePtr m_headerPathsCache;
|
||||
|
||||
friend class KeilToolchainFactory;
|
||||
friend class KeilToolchainConfigWidget;
|
||||
};
|
||||
|
@@ -217,9 +217,7 @@ static Utils::FileName compilerPathFromEnvironment(const QString &compilerName)
|
||||
// SdccToolChain
|
||||
|
||||
SdccToolChain::SdccToolChain(Detection d) :
|
||||
ToolChain(Constants::SDCC_TOOLCHAIN_TYPEID, d),
|
||||
m_predefinedMacrosCache(std::make_shared<Cache<MacroInspectionReport, 64>>()),
|
||||
m_headerPathsCache(std::make_shared<HeaderPathsCache>())
|
||||
ToolChain(Constants::SDCC_TOOLCHAIN_TYPEID, d)
|
||||
{ }
|
||||
|
||||
SdccToolChain::SdccToolChain(Core::Id language, Detection d) :
|
||||
@@ -260,7 +258,7 @@ ToolChain::MacroInspectionRunner SdccToolChain::createMacroInspectionRunner() co
|
||||
const Core::Id lang = language();
|
||||
const Abi abi = m_targetAbi;
|
||||
|
||||
MacrosCache macrosCache = m_predefinedMacrosCache;
|
||||
MacrosCache macrosCache = predefinedMacrosCache();
|
||||
|
||||
return [env, compilerCommand, macrosCache, lang, abi]
|
||||
(const QStringList &flags) {
|
||||
@@ -300,16 +298,16 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
||||
const Core::Id languageId = language();
|
||||
const Abi abi = m_targetAbi;
|
||||
|
||||
HeaderPathsCachePtr headerPathsCache = m_headerPathsCache;
|
||||
HeaderPathsCache headerPaths = headerPathsCache();
|
||||
|
||||
return [env, compilerCommand, headerPathsCache, languageId, abi](const QStringList &flags,
|
||||
const QString &fileName,
|
||||
const QString &) {
|
||||
return [env, compilerCommand, headerPaths, languageId, abi](const QStringList &flags,
|
||||
const QString &fileName,
|
||||
const QString &) {
|
||||
Q_UNUSED(flags)
|
||||
Q_UNUSED(fileName)
|
||||
|
||||
const HeaderPaths paths = dumpHeaderPaths(compilerCommand, env.toStringList(), abi);
|
||||
headerPathsCache->insert({}, paths);
|
||||
headerPaths->insert({}, paths);
|
||||
|
||||
return paths;
|
||||
};
|
||||
@@ -391,13 +389,6 @@ ToolChain *SdccToolChain::clone() const
|
||||
return new SdccToolChain(*this);
|
||||
}
|
||||
|
||||
void SdccToolChain::toolChainUpdated()
|
||||
{
|
||||
m_predefinedMacrosCache->invalidate();
|
||||
m_headerPathsCache->invalidate();
|
||||
ToolChain::toolChainUpdated();
|
||||
}
|
||||
|
||||
// SdccToolChainFactory
|
||||
|
||||
SdccToolChainFactory::SdccToolChainFactory()
|
||||
@@ -519,7 +510,7 @@ QList<ToolChain *> SdccToolChainFactory::autoDetectToolchain(
|
||||
tc->setDisplayName(buildDisplayName(abi.architecture(), language, candidate.second));
|
||||
|
||||
const auto languageVersion = ToolChain::languageVersion(language, macros);
|
||||
tc->m_predefinedMacrosCache->insert({}, {macros, languageVersion});
|
||||
tc->predefinedMacrosCache()->insert({}, {macros, languageVersion});
|
||||
return {tc};
|
||||
}
|
||||
|
||||
@@ -561,7 +552,7 @@ void SdccToolChainConfigWidget::applyImpl()
|
||||
return;
|
||||
|
||||
const auto languageVersion = ToolChain::languageVersion(tc->language(), m_macros);
|
||||
tc->m_predefinedMacrosCache->insert({}, {m_macros, languageVersion});
|
||||
tc->predefinedMacrosCache()->insert({}, {m_macros, languageVersion});
|
||||
|
||||
setFromToolchain();
|
||||
}
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/toolchaincache.h>
|
||||
#include <projectexplorer/toolchainconfigwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -86,8 +85,6 @@ public:
|
||||
|
||||
ToolChain *clone() const final;
|
||||
|
||||
void toolChainUpdated() final;
|
||||
|
||||
protected:
|
||||
SdccToolChain(const SdccToolChain &tc) = default;
|
||||
|
||||
@@ -98,13 +95,6 @@ private:
|
||||
ProjectExplorer::Abi m_targetAbi;
|
||||
Utils::FileName m_compilerCommand;
|
||||
|
||||
using MacrosCache = std::shared_ptr<ProjectExplorer::Cache<MacroInspectionReport, 64>>;
|
||||
mutable MacrosCache m_predefinedMacrosCache;
|
||||
|
||||
using HeaderPathsCache = ProjectExplorer::Cache<ProjectExplorer::HeaderPaths>;
|
||||
using HeaderPathsCachePtr = std::shared_ptr<HeaderPathsCache>;
|
||||
mutable HeaderPathsCachePtr m_headerPathsCache;
|
||||
|
||||
friend class SdccToolChainFactory;
|
||||
friend class SdccToolChainConfigWidget;
|
||||
};
|
||||
|
@@ -167,13 +167,6 @@ HeaderPaths GccToolChain::gccHeaderPaths(const FileName &gcc, const QStringList
|
||||
return builtInHeaderPaths;
|
||||
}
|
||||
|
||||
void GccToolChain::toolChainUpdated()
|
||||
{
|
||||
m_predefinedMacrosCache->invalidate();
|
||||
m_headerPathsCache->invalidate();
|
||||
ToolChain::toolChainUpdated();
|
||||
}
|
||||
|
||||
static QList<Abi> guessGccAbi(const QString &m, const ProjectExplorer::Macros ¯os)
|
||||
{
|
||||
QList<Abi> abiList;
|
||||
@@ -244,9 +237,7 @@ GccToolChain::GccToolChain(Detection d) :
|
||||
{ }
|
||||
|
||||
GccToolChain::GccToolChain(Core::Id typeId, Detection d) :
|
||||
ToolChain(typeId, d),
|
||||
m_headerPathsCache(std::make_shared<Cache<HeaderPaths>>()),
|
||||
m_predefinedMacrosCache(std::make_shared<Cache<MacroInspectionReport, 64>>())
|
||||
ToolChain(typeId, d)
|
||||
{ }
|
||||
|
||||
void GccToolChain::setCompilerCommand(const FileName &path)
|
||||
@@ -382,7 +373,7 @@ ToolChain::MacroInspectionRunner GccToolChain::createMacroInspectionRunner() con
|
||||
const QStringList platformCodeGenFlags = m_platformCodeGenFlags;
|
||||
OptionsReinterpreter reinterpretOptions = m_optionsReinterpreter;
|
||||
QTC_CHECK(reinterpretOptions);
|
||||
std::shared_ptr<Cache<MacroInspectionReport, 64>> macroCache = m_predefinedMacrosCache;
|
||||
MacrosCache macroCache = predefinedMacrosCache();
|
||||
Core::Id lang = language();
|
||||
|
||||
// This runner must be thread-safe!
|
||||
@@ -573,7 +564,7 @@ HeaderPaths GccToolChain::builtInHeaderPaths(const Utils::Environment &env,
|
||||
const Utils::FileName &compilerCommand,
|
||||
const QStringList &platformCodeGenFlags,
|
||||
OptionsReinterpreter reinterpretOptions,
|
||||
std::shared_ptr<Cache<HeaderPaths>> headerCache,
|
||||
HeaderPathsCache headerCache,
|
||||
Core::Id languageId,
|
||||
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
||||
const QStringList &flags,
|
||||
@@ -621,7 +612,7 @@ ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner
|
||||
compilerCommand = m_compilerCommand,
|
||||
platformCodeGenFlags = m_platformCodeGenFlags,
|
||||
reinterpretOptions = m_optionsReinterpreter,
|
||||
headerCache = m_headerPathsCache,
|
||||
headerCache = headerPathsCache(),
|
||||
languageId = language(),
|
||||
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
||||
const QString &sysRoot,
|
||||
@@ -1064,7 +1055,7 @@ QList<ToolChain *> GccToolChainFactory::autoDetectToolChain(const FileName &comp
|
||||
return result;
|
||||
|
||||
tc->setLanguage(language);
|
||||
tc->m_predefinedMacrosCache
|
||||
tc->predefinedMacrosCache()
|
||||
->insert(QStringList(),
|
||||
ToolChain::MacroInspectionReport{macros,
|
||||
ToolChain::languageVersion(language, macros)});
|
||||
@@ -1138,7 +1129,7 @@ void GccToolChainConfigWidget::applyImpl()
|
||||
if (m_macros.isEmpty())
|
||||
return;
|
||||
|
||||
tc->m_predefinedMacrosCache
|
||||
tc->predefinedMacrosCache()
|
||||
->insert(tc->platformCodeGenFlags(),
|
||||
ToolChain::MacroInspectionReport{m_macros,
|
||||
ToolChain::languageVersion(tc->language(),
|
||||
@@ -1446,7 +1437,7 @@ ToolChain::BuiltInHeaderPathsRunner ClangToolChain::createBuiltInHeaderPathsRunn
|
||||
compilerCommand = m_compilerCommand,
|
||||
platformCodeGenFlags = m_platformCodeGenFlags,
|
||||
reinterpretOptions = m_optionsReinterpreter,
|
||||
headerCache = m_headerPathsCache,
|
||||
headerCache = headerPathsCache(),
|
||||
languageId = language(),
|
||||
extraHeaderPathsFunction = m_extraHeaderPathsFunction](const QStringList &flags,
|
||||
const QString &sysRoot,
|
||||
|
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "projectexplorerconstants.h"
|
||||
#include "toolchain.h"
|
||||
#include "toolchaincache.h"
|
||||
#include "abi.h"
|
||||
#include "headerpath.h"
|
||||
|
||||
@@ -155,7 +154,7 @@ protected:
|
||||
const Utils::FileName &compilerCommand,
|
||||
const QStringList &platformCodeGenFlags,
|
||||
OptionsReinterpreter reinterpretOptions,
|
||||
std::shared_ptr<Cache<HeaderPaths>> headerCache,
|
||||
HeaderPathsCache headerCache,
|
||||
Core::Id languageId,
|
||||
ExtraHeaderPathsFunction extraHeaderPathsFunction,
|
||||
const QStringList &flags,
|
||||
@@ -178,7 +177,6 @@ protected:
|
||||
bool m_doesEnable = false;
|
||||
bool m_triggered = false;
|
||||
};
|
||||
void toolChainUpdated() override;
|
||||
|
||||
private:
|
||||
explicit GccToolChain(Detection d);
|
||||
@@ -196,7 +194,6 @@ protected:
|
||||
QStringList m_platformLinkerFlags;
|
||||
|
||||
OptionsReinterpreter m_optionsReinterpreter = [](const QStringList &v) { return v; };
|
||||
mutable std::shared_ptr<Cache<HeaderPaths>> m_headerPathsCache;
|
||||
mutable ExtraHeaderPathsFunction m_extraHeaderPathsFunction = [](HeaderPaths &) {};
|
||||
|
||||
private:
|
||||
@@ -206,8 +203,6 @@ private:
|
||||
mutable HeaderPaths m_headerPaths;
|
||||
mutable QString m_version;
|
||||
|
||||
mutable std::shared_ptr<Cache<MacroInspectionReport, 64>> m_predefinedMacrosCache;
|
||||
|
||||
friend class Internal::GccToolChainConfigWidget;
|
||||
friend class Internal::GccToolChainFactory;
|
||||
friend class ToolChainFactory;
|
||||
|
@@ -792,7 +792,6 @@ MsvcToolChain::MsvcToolChain(const MsvcToolChain &other)
|
||||
, m_headerPathsMutex(new QMutex)
|
||||
, m_environmentModifications(other.m_environmentModifications)
|
||||
, m_debuggerCommand(other.m_debuggerCommand)
|
||||
, m_predefinedMacrosCache(other.m_predefinedMacrosCache)
|
||||
, m_lastEnvironment(other.m_lastEnvironment)
|
||||
, m_resultEnvironment(other.m_resultEnvironment)
|
||||
, m_abi(other.m_abi)
|
||||
@@ -833,7 +832,6 @@ MsvcToolChain::MsvcToolChain(Core::Id typeId,
|
||||
Detection d)
|
||||
: ToolChain(typeId, d)
|
||||
, m_headerPathsMutex(new QMutex)
|
||||
, m_predefinedMacrosCache(std::make_shared<Cache<MacroInspectionReport, 64>>())
|
||||
, m_lastEnvironment(Utils::Environment::systemEnvironment())
|
||||
, m_abi(abi)
|
||||
, m_vcvarsBat(varsBat)
|
||||
@@ -854,7 +852,6 @@ MsvcToolChain::MsvcToolChain(Core::Id typeId,
|
||||
|
||||
MsvcToolChain::MsvcToolChain(Core::Id typeId)
|
||||
: ToolChain(typeId, ManualDetection)
|
||||
, m_predefinedMacrosCache(std::make_shared<Cache<MacroInspectionReport, 64>>())
|
||||
, m_lastEnvironment(Utils::Environment::systemEnvironment())
|
||||
{}
|
||||
|
||||
@@ -877,11 +874,6 @@ void MsvcToolChain::inferWarningsForLevel(int warningLevel, WarningFlags &flags)
|
||||
flags |= WarningFlags::UnusedParams;
|
||||
}
|
||||
|
||||
void MsvcToolChain::toolChainUpdated()
|
||||
{
|
||||
m_predefinedMacrosCache->invalidate();
|
||||
}
|
||||
|
||||
MsvcToolChain::MsvcToolChain()
|
||||
: MsvcToolChain(Constants::MSVC_TOOLCHAIN_TYPEID)
|
||||
{}
|
||||
@@ -1039,7 +1031,7 @@ ToolChain::MacroInspectionRunner MsvcToolChain::createMacroInspectionRunner() co
|
||||
{
|
||||
Utils::Environment env(m_lastEnvironment);
|
||||
addToEnvironment(env);
|
||||
std::shared_ptr<Cache<MacroInspectionReport, 64>> macroCache = m_predefinedMacrosCache;
|
||||
MacrosCache macroCache = predefinedMacrosCache();
|
||||
const Core::Id lang = language();
|
||||
|
||||
// This runner must be thread-safe!
|
||||
@@ -1631,12 +1623,6 @@ Utils::LanguageVersion ClangClToolChain::msvcLanguageVersion(const QStringList &
|
||||
return MsvcToolChain::msvcLanguageVersion(cxxflags, language, macros);
|
||||
}
|
||||
|
||||
void ClangClToolChain::toolChainUpdated()
|
||||
{
|
||||
MsvcToolChain::toolChainUpdated();
|
||||
ToolChain::toolChainUpdated();
|
||||
}
|
||||
|
||||
ClangClToolChain::BuiltInHeaderPathsRunner ClangClToolChain::createBuiltInHeaderPathsRunner() const
|
||||
{
|
||||
{
|
||||
|
@@ -27,7 +27,6 @@
|
||||
|
||||
#include "abi.h"
|
||||
#include "toolchain.h"
|
||||
#include "toolchaincache.h"
|
||||
#include "toolchainconfigwidget.h"
|
||||
|
||||
#include <QFutureWatcher>
|
||||
@@ -136,7 +135,6 @@ protected:
|
||||
explicit MsvcToolChain(Core::Id typeId);
|
||||
|
||||
static void inferWarningsForLevel(int warningLevel, WarningFlags &flags);
|
||||
void toolChainUpdated() override;
|
||||
|
||||
Utils::Environment readEnvironmentSetting(const Utils::Environment &env) const;
|
||||
// Function must be thread-safe!
|
||||
@@ -169,8 +167,6 @@ private:
|
||||
|
||||
Utils::FileName m_debuggerCommand;
|
||||
|
||||
mutable std::shared_ptr<Cache<MacroInspectionReport, 64>> m_predefinedMacrosCache;
|
||||
|
||||
mutable Utils::Environment m_lastEnvironment; // Last checked 'incoming' environment.
|
||||
mutable Utils::Environment m_resultEnvironment; // Resulting environment for VC
|
||||
|
||||
@@ -214,9 +210,6 @@ public:
|
||||
|
||||
bool operator==(const ToolChain &) const override;
|
||||
|
||||
private:
|
||||
void toolChainUpdated() override;
|
||||
|
||||
private:
|
||||
QString m_clangPath;
|
||||
};
|
||||
|
@@ -58,7 +58,9 @@ public:
|
||||
explicit ToolChainPrivate(Core::Id typeId, Detection d) :
|
||||
m_id(QUuid::createUuid().toByteArray()),
|
||||
m_typeId(typeId),
|
||||
m_detection(d)
|
||||
m_detection(d),
|
||||
m_predefinedMacrosCache(new ToolChain::MacrosCache::element_type()),
|
||||
m_headerPathsCache(new ToolChain::HeaderPathsCache::element_type())
|
||||
{
|
||||
QTC_ASSERT(m_typeId.isValid(), return);
|
||||
QTC_ASSERT(!m_typeId.toString().contains(QLatin1Char(':')), return);
|
||||
@@ -70,6 +72,9 @@ public:
|
||||
Core::Id m_typeId;
|
||||
Core::Id m_language;
|
||||
Detection m_detection;
|
||||
|
||||
ToolChain::MacrosCache m_predefinedMacrosCache;
|
||||
ToolChain::HeaderPathsCache m_headerPathsCache;
|
||||
};
|
||||
|
||||
|
||||
@@ -236,6 +241,9 @@ QVariantMap ToolChain::toMap() const
|
||||
|
||||
void ToolChain::toolChainUpdated()
|
||||
{
|
||||
d->m_predefinedMacrosCache->invalidate();
|
||||
d->m_headerPathsCache->invalidate();
|
||||
|
||||
ToolChainManager::notifyAboutUpdate(this);
|
||||
}
|
||||
|
||||
@@ -286,6 +294,16 @@ bool ToolChain::fromMap(const QVariantMap &data)
|
||||
return true;
|
||||
}
|
||||
|
||||
const ToolChain::HeaderPathsCache &ToolChain::headerPathsCache() const
|
||||
{
|
||||
return d->m_headerPathsCache;
|
||||
}
|
||||
|
||||
const ToolChain::MacrosCache &ToolChain::predefinedMacrosCache() const
|
||||
{
|
||||
return d->m_predefinedMacrosCache;
|
||||
}
|
||||
|
||||
static long toLanguageVersionAsLong(QByteArray dateAsByteArray)
|
||||
{
|
||||
dateAsByteArray.chop(1); // Strip 'L'.
|
||||
|
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "headerpath.h"
|
||||
#include "projectmacro.h"
|
||||
#include "toolchaincache.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
@@ -120,6 +121,9 @@ public:
|
||||
Utils::LanguageVersion languageVersion;
|
||||
};
|
||||
|
||||
using MacrosCache = std::shared_ptr<Cache<ToolChain::MacroInspectionReport, 64>>;
|
||||
using HeaderPathsCache = std::shared_ptr<Cache<HeaderPaths>>;
|
||||
|
||||
// A MacroInspectionRunner is created in the ui thread and runs in another thread.
|
||||
using MacroInspectionRunner = std::function<MacroInspectionReport(const QStringList &cxxflags)>;
|
||||
virtual MacroInspectionRunner createMacroInspectionRunner() const = 0;
|
||||
@@ -160,6 +164,9 @@ protected:
|
||||
explicit ToolChain(Core::Id typeId, Detection d);
|
||||
explicit ToolChain(const ToolChain &);
|
||||
|
||||
const MacrosCache &predefinedMacrosCache() const;
|
||||
const HeaderPathsCache &headerPathsCache() const;
|
||||
|
||||
virtual void toolChainUpdated();
|
||||
|
||||
// Make sure to call this function when deriving!
|
||||
|
Reference in New Issue
Block a user