Adapt to removal of ToolChain::type()

QtC change: e6d1141e1e

Change-Id: I50c0861dc6a864e54170b21de94a4106921e5a71
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-07-07 15:24:47 +02:00
parent d8a176cae7
commit 7bdf007c86
5 changed files with 20 additions and 15 deletions

View File

@@ -143,14 +143,15 @@ public:
// Therefore, prevent the inclusion of the header that references them. Of course, this // Therefore, prevent the inclusion of the header that references them. Of course, this
// will break if code actually requires stuff from there, but that should be the less common // will break if code actually requires stuff from there, but that should be the less common
// case. // case.
const QString type = projectPart->toolchainType; const Core::Id type = projectPart->toolchainType;
if (type == QLatin1String("mingw") || type == QLatin1String("gcc")) if (type == ProjectExplorer::Constants::MINGW_TOOLCHAIN_ID
|| type == ProjectExplorer::Constants::GCC_TOOLCHAIN_ID)
optionsBuilder.addDefine("#define _X86INTRIN_H_INCLUDED\n"); optionsBuilder.addDefine("#define _X86INTRIN_H_INCLUDED\n");
optionsBuilder.addToolchainAndProjectDefines(); optionsBuilder.addToolchainAndProjectDefines();
optionsBuilder.addHeaderPathOptions(); optionsBuilder.addHeaderPathOptions();
if (projectPart->toolchainType == QLatin1String("msvc")) if (type == ProjectExplorer::Constants::MSVC_TOOLCHAIN_ID)
optionsBuilder.add(QLatin1String("/EHsc")); // clang-cl does not understand exceptions optionsBuilder.add(QLatin1String("/EHsc")); // clang-cl does not understand exceptions
else else
optionsBuilder.add(QLatin1String("-fPIC")); // TODO: Remove? optionsBuilder.add(QLatin1String("-fPIC")); // TODO: Remove?
@@ -163,7 +164,7 @@ public:
private: private:
ClangStaticAnalyzerOptionsBuilder(const CppTools::ProjectPart::Ptr &projectPart) ClangStaticAnalyzerOptionsBuilder(const CppTools::ProjectPart::Ptr &projectPart)
: CompilerOptionsBuilder(projectPart) : CompilerOptionsBuilder(projectPart)
, m_isMsvcToolchain(m_projectPart->toolchainType == QLatin1String("msvc")) , m_isMsvcToolchain(m_projectPart->toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_ID)
{ {
} }
@@ -281,10 +282,10 @@ static QDebug operator<<(QDebug debug, const AnalyzeUnits &analyzeUnits)
return debug; return debug;
} }
static QString toolchainType(ProjectExplorer::RunConfiguration *runConfiguration) static Core::Id toolchainType(ProjectExplorer::RunConfiguration *runConfiguration)
{ {
QTC_ASSERT(runConfiguration, return QString()); QTC_ASSERT(runConfiguration, return Core::Id());
return ToolChainKitInformation::toolChain(runConfiguration->target()->kit())->type(); return ToolChainKitInformation::toolChain(runConfiguration->target()->kit())->typeId();
} }
bool ClangStaticAnalyzerRunControl::startEngine() bool ClangStaticAnalyzerRunControl::startEngine()

View File

@@ -63,10 +63,10 @@ bool ClangStaticAnalyzerRunControlFactory::canRun(RunConfiguration *runConfigura
Kit *kit = target->kit(); Kit *kit = target->kit();
QTC_ASSERT(kit, return false); QTC_ASSERT(kit, return false);
ToolChain *toolChain = ToolChainKitInformation::toolChain(kit); ToolChain *toolChain = ToolChainKitInformation::toolChain(kit);
return toolChain && (toolChain->type() == QLatin1String("clang") return toolChain && (toolChain->typeId() == ProjectExplorer::Constants::CLANG_TOOLCHAIN_ID
|| toolChain->type() == QLatin1String("gcc") || toolChain->typeId() == ProjectExplorer::Constants::GCC_TOOLCHAIN_ID
|| toolChain->type() == QLatin1String("mingw") || toolChain->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_ID
|| toolChain->type() == QLatin1String("msvc")); || toolChain->typeId() == ProjectExplorer::Constants::MSVC_TOOLCHAIN_ID);
} }
RunControl *ClangStaticAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration, RunControl *ClangStaticAnalyzerRunControlFactory::create(RunConfiguration *runConfiguration,

View File

@@ -61,7 +61,7 @@ void ClangStaticAnalyzerUnitTests::initTestCase()
if (!toolchain) if (!toolchain)
QSKIP("This test requires that there is a kit with a toolchain."); QSKIP("This test requires that there is a kit with a toolchain.");
bool hasClangExecutable; bool hasClangExecutable;
clangExecutableFromSettings(toolchain->type(), &hasClangExecutable); clangExecutableFromSettings(toolchain->typeId(), &hasClangExecutable);
if (!hasClangExecutable) if (!hasClangExecutable)
QSKIP("No clang suitable for analyzing found"); QSKIP("No clang suitable for analyzing found");

View File

@@ -21,6 +21,8 @@
#include "clangstaticanalyzerdiagnostic.h" #include "clangstaticanalyzerdiagnostic.h"
#include "clangstaticanalyzersettings.h" #include "clangstaticanalyzersettings.h"
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -38,10 +40,10 @@ static bool isFileExecutable(const QString &executablePath)
namespace ClangStaticAnalyzer { namespace ClangStaticAnalyzer {
namespace Internal { namespace Internal {
QString clangExecutableFromSettings(const QString &toolchainType, bool *isValid) QString clangExecutableFromSettings(Core::Id toolchainType, bool *isValid)
{ {
QString exeFromSettings = ClangStaticAnalyzerSettings::instance()->clangExecutable(); QString exeFromSettings = ClangStaticAnalyzerSettings::instance()->clangExecutable();
if (toolchainType == QLatin1String("msvc")) if (toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_ID)
exeFromSettings.replace(QLatin1String("clang.exe"), QLatin1String("clang-cl.exe")); exeFromSettings.replace(QLatin1String("clang.exe"), QLatin1String("clang-cl.exe"));
return clangExecutable(exeFromSettings, isValid); return clangExecutable(exeFromSettings, isValid);
} }

View File

@@ -19,6 +19,8 @@
#ifndef CLANGSTATICANALYZERUTILS_H #ifndef CLANGSTATICANALYZERUTILS_H
#define CLANGSTATICANALYZERUTILS_H #define CLANGSTATICANALYZERUTILS_H
#include <coreplugin/id.h>
#include <QtGlobal> #include <QtGlobal>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@@ -33,7 +35,7 @@ class Location;
bool isClangExecutableUsable(const QString &filePath, QString *errorMessage = 0); bool isClangExecutableUsable(const QString &filePath, QString *errorMessage = 0);
QString clangExecutable(const QString &fileNameOrPath, bool *isValid); QString clangExecutable(const QString &fileNameOrPath, bool *isValid);
QString clangExecutableFromSettings(const QString &toolchainType, bool *isValid); QString clangExecutableFromSettings(Core::Id toolchainType, bool *isValid);
QString createFullLocationString(const ClangStaticAnalyzer::Internal::Location &location); QString createFullLocationString(const ClangStaticAnalyzer::Internal::Location &location);