Commit 68a49c79 authored by Ivan Donchevskii's avatar Ivan Donchevskii

Clang: Unify compiler options builders

Make build command the same for all builders.
Minimize differences.

Change-Id: I1cfe5071b3afb4944ed178fff1e57d3aee45d8a9
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 736e568d
...@@ -223,8 +223,6 @@ def deploy_libclang(install_dir, llvm_install_dir, chrpath_bin): ...@@ -223,8 +223,6 @@ def deploy_libclang(install_dir, llvm_install_dir, chrpath_bin):
os.path.join(install_dir, 'bin'))) os.path.join(install_dir, 'bin')))
deployinfo.append((os.path.join(llvm_install_dir, 'bin', 'clang.exe'), deployinfo.append((os.path.join(llvm_install_dir, 'bin', 'clang.exe'),
clangbindirtarget)) clangbindirtarget))
deployinfo.append((os.path.join(llvm_install_dir, 'bin', 'clang-cl.exe'),
clangbindirtarget))
resourcetarget = os.path.join(clanglibdirtarget, 'clang') resourcetarget = os.path.join(clanglibdirtarget, 'clang')
else: else:
libsources = glob(os.path.join(llvm_install_dir, 'lib', 'libclang.so*')) libsources = glob(os.path.join(llvm_install_dir, 'lib', 'libclang.so*'))
......
...@@ -70,46 +70,21 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, const QString &fil ...@@ -70,46 +70,21 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, const QString &fil
return createClangOptions(pPart, fileKind); return createClangOptions(pPart, fileKind);
} }
class LibClangOptionsBuilder : public ClangCompilerOptionsBuilder class LibClangOptionsBuilder final : public ClangCompilerOptionsBuilder
{ {
public: public:
static QStringList build(const ProjectPart::Ptr &projectPart, ProjectFile::Kind fileKind) LibClangOptionsBuilder(const ProjectPart &projectPart)
: ClangCompilerOptionsBuilder(projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR)
{ {
if (projectPart.isNull())
return QStringList();
LibClangOptionsBuilder optionsBuilder(*projectPart.data());
optionsBuilder.addWordWidth();
optionsBuilder.addTargetTriple();
optionsBuilder.addLanguageOption(fileKind);
optionsBuilder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
optionsBuilder.enableExceptions();
optionsBuilder.addDefineToAvoidIncludingGccOrMinGwIntrinsics();
optionsBuilder.addDefineFloat128ForMingw();
optionsBuilder.addToolchainAndProjectDefines();
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
optionsBuilder.addPredefinedMacrosAndHeaderPathsOptions();
optionsBuilder.addWrappedQtHeadersIncludePath();
optionsBuilder.addHeaderPathOptions();
optionsBuilder.addDummyUiHeaderOnDiskIncludePath();
optionsBuilder.addProjectConfigFileInclude();
optionsBuilder.addMsvcCompatibilityVersion();
optionsBuilder.addExtraOptions();
return optionsBuilder.options();
} }
private: void addExtraOptions() final
LibClangOptionsBuilder(const CppTools::ProjectPart &projectPart)
: ClangCompilerOptionsBuilder(projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR)
{ {
addDummyUiHeaderOnDiskIncludePath();
ClangCompilerOptionsBuilder::addExtraOptions();
} }
private:
void addDummyUiHeaderOnDiskIncludePath() void addDummyUiHeaderOnDiskIncludePath()
{ {
const QString path = ModelManagerSupportClang::instance()->dummyUiHeaderOnDiskDirPath(); const QString path = ModelManagerSupportClang::instance()->dummyUiHeaderOnDiskDirPath();
...@@ -125,7 +100,9 @@ private: ...@@ -125,7 +100,9 @@ private:
*/ */
QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind) QStringList createClangOptions(const ProjectPart::Ptr &pPart, ProjectFile::Kind fileKind)
{ {
return LibClangOptionsBuilder::build(pPart, fileKind); if (!pPart)
return QStringList();
return LibClangOptionsBuilder(*pPart).build(fileKind, CompilerOptionsBuilder::PchUsage::None);
} }
ProjectPart::Ptr projectPartForFile(const QString &filePath) ProjectPart::Ptr projectPartForFile(const QString &filePath)
......
...@@ -108,35 +108,9 @@ HeaderAndSources ProjectUpdater::headerAndSourcesFromProjectPart( ...@@ -108,35 +108,9 @@ HeaderAndSources ProjectUpdater::headerAndSourcesFromProjectPart(
QStringList ProjectUpdater::compilerArguments(CppTools::ProjectPart *projectPart) QStringList ProjectUpdater::compilerArguments(CppTools::ProjectPart *projectPart)
{ {
using CppTools::ClangCompilerOptionsBuilder; using ClangCOBuilder = CppTools::ClangCompilerOptionsBuilder;
ClangCOBuilder builder(*projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR);
ClangCompilerOptionsBuilder builder(*projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR); return builder.build(CppTools::ProjectFile::CXXHeader, ClangCOBuilder::PchUsage::None);
builder.addWordWidth();
builder.addTargetTriple();
builder.addLanguageOption(CppTools::ProjectFile::CXXHeader);
builder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
builder.enableExceptions();
builder.addDefineToAvoidIncludingGccOrMinGwIntrinsics();
builder.addDefineFloat128ForMingw();
builder.addToolchainAndProjectDefines();
builder.undefineCppLanguageFeatureMacrosForMsvc2015();
builder.addPredefinedMacrosAndHeaderPathsOptions();
builder.addWrappedQtHeadersIncludePath();
builder.addPrecompiledHeaderOptions(ClangCompilerOptionsBuilder::PchUsage::None);
builder.addHeaderPathOptions();
builder.addProjectConfigFileInclude();
builder.addMsvcCompatibilityVersion();
builder.add("-fmessage-length=0");
builder.add("-fmacro-backtrace-limit=0");
builder.add("-w");
builder.add("-ferror-limit=100000");
return builder.options();
} }
ClangBackEnd::V2::ProjectPartContainer ProjectUpdater::toProjectPartContainer( ClangBackEnd::V2::ProjectPartContainer ProjectUpdater::toProjectPartContainer(
......
...@@ -155,31 +155,8 @@ Utils::SmallStringVector ClangQueryProjectsFindFilter::compilerArguments(CppTool ...@@ -155,31 +155,8 @@ Utils::SmallStringVector ClangQueryProjectsFindFilter::compilerArguments(CppTool
ClangCompilerOptionsBuilder builder(*projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR); ClangCompilerOptionsBuilder builder(*projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR);
builder.addWordWidth(); return Utils::SmallStringVector(builder.build(fileKind,
builder.addTargetTriple(); ClangCompilerOptionsBuilder::PchUsage::None));
builder.addLanguageOption(fileKind);
builder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
builder.enableExceptions();
builder.addDefineToAvoidIncludingGccOrMinGwIntrinsics();
builder.addDefineFloat128ForMingw();
builder.addToolchainAndProjectDefines();
builder.undefineCppLanguageFeatureMacrosForMsvc2015();
builder.addPredefinedMacrosAndHeaderPathsOptions();
builder.addWrappedQtHeadersIncludePath();
builder.addPrecompiledHeaderOptions(ClangCompilerOptionsBuilder::PchUsage::None);
builder.addHeaderPathOptions();
builder.addProjectConfigFileInclude();
builder.addMsvcCompatibilityVersion();
builder.add("-fmessage-length=0");
builder.add("-fmacro-backtrace-limit=0");
builder.add("-w");
builder.add("-ferror-limit=1000000");
return Utils::SmallStringVector(builder.options());
} }
QWidget *ClangQueryProjectsFindFilter::widget() const QWidget *ClangQueryProjectsFindFilter::widget() const
......
...@@ -64,12 +64,10 @@ void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data, ...@@ -64,12 +64,10 @@ void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
QString filePath = data.filePath().toString(); QString filePath = data.filePath().toString();
QTextCursor textCursor = data.cursor(); QTextCursor textCursor = data.cursor();
Utils::SmallStringVector commandLine{ClangCompilerOptionsBuilder::build( ClangCompilerOptionsBuilder clangCOBuilder{*projectPart, CLANG_VERSION, CLANG_RESOURCE_DIR};
projectPart, Utils::SmallStringVector commandLine{clangCOBuilder.build(
fileKindInProjectPart(projectPart, filePath), fileKindInProjectPart(projectPart, filePath),
CppTools::getPchUsage(), CppTools::getPchUsage())};
CLANG_VERSION,
CLANG_RESOURCE_DIR)};
commandLine.push_back(filePath); commandLine.push_back(filePath);
......
...@@ -167,7 +167,7 @@ static QList<Target *> validTargets(Project *project) ...@@ -167,7 +167,7 @@ static QList<Target *> validTargets(Project *project)
const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID); const ToolChain * const toolchain = ToolChainKitInformation::toolChain(kit, ProjectExplorer::Constants::CXX_LANGUAGE_ID);
QTC_ASSERT(toolchain, return false); QTC_ASSERT(toolchain, return false);
bool hasClangExecutable; bool hasClangExecutable;
clangExecutableFromSettings(toolchain->typeId(), &hasClangExecutable); clangExecutableFromSettings(&hasClangExecutable);
if (!hasClangExecutable) { if (!hasClangExecutable) {
qWarning("Project \"%s\": Skipping target \"%s\" since no suitable clang was found for the toolchain.", qWarning("Project \"%s\": Skipping target \"%s\" since no suitable clang was found for the toolchain.",
qPrintable(projectFileName), qPrintable(projectFileName),
......
...@@ -58,7 +58,7 @@ void ClangStaticAnalyzerUnitTests::initTestCase() ...@@ -58,7 +58,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->typeId(), &hasClangExecutable); clangExecutableFromSettings(&hasClangExecutable);
if (!hasClangExecutable) if (!hasClangExecutable)
QSKIP("No clang suitable for analyzing found"); QSKIP("No clang suitable for analyzing found");
......
...@@ -50,7 +50,7 @@ static bool isFileExecutable(const QString &executablePath) ...@@ -50,7 +50,7 @@ static bool isFileExecutable(const QString &executablePath)
namespace ClangStaticAnalyzer { namespace ClangStaticAnalyzer {
namespace Internal { namespace Internal {
QString clangExecutableFromSettings(Core::Id toolchainType, bool *isValid) QString clangExecutableFromSettings(bool *isValid)
{ {
QString executable = ClangStaticAnalyzerSettings::instance()->clangExecutable(); QString executable = ClangStaticAnalyzerSettings::instance()->clangExecutable();
if (executable.isEmpty()) { if (executable.isEmpty()) {
...@@ -62,14 +62,6 @@ QString clangExecutableFromSettings(Core::Id toolchainType, bool *isValid) ...@@ -62,14 +62,6 @@ QString clangExecutableFromSettings(Core::Id toolchainType, bool *isValid)
const Qt::CaseSensitivity caseSensitivity = Utils::HostOsInfo::fileNameCaseSensitivity(); const Qt::CaseSensitivity caseSensitivity = Utils::HostOsInfo::fileNameCaseSensitivity();
const bool hasSuffix = executable.endsWith(hostExeSuffix, caseSensitivity); const bool hasSuffix = executable.endsWith(hostExeSuffix, caseSensitivity);
if (toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID) {
if (hasSuffix)
executable.chop(hostExeSuffix.length());
executable.append(QLatin1String("-cl"));
if (hasSuffix)
executable.append(hostExeSuffix);
}
const QFileInfo fileInfo = QFileInfo(executable); const QFileInfo fileInfo = QFileInfo(executable);
if (fileInfo.isAbsolute()) { if (fileInfo.isAbsolute()) {
if (!hasSuffix) if (!hasSuffix)
......
...@@ -41,7 +41,7 @@ namespace Internal { ...@@ -41,7 +41,7 @@ namespace Internal {
bool isClangExecutableUsable(const QString &filePath, QString *errorMessage = 0); bool isClangExecutableUsable(const QString &filePath, QString *errorMessage = 0);
QString clangExecutableFromSettings(Core::Id toolchainType, bool *isValid); QString clangExecutableFromSettings(bool *isValid);
QString createFullLocationString(const Debugger::DiagnosticLocation &location); QString createFullLocationString(const Debugger::DiagnosticLocation &location);
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "clangcompileroptionsbuilder.h" #include "clangcompileroptionsbuilder.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
...@@ -38,46 +37,46 @@ namespace CppTools { ...@@ -38,46 +37,46 @@ namespace CppTools {
static QString creatorResourcePath() static QString creatorResourcePath()
{ {
#ifndef UNIT_TESTS #ifndef UNIT_TESTS
return Core::ICore::instance()->libexecPath(); return Core::ICore::instance()->resourcePath();
#else #else
return QString(); return QString();
#endif #endif
} }
QStringList ClangCompilerOptionsBuilder::build(const CppTools::ProjectPart *projectPart, static QString creatorLibexecPath()
CppTools::ProjectFile::Kind fileKind,
PchUsage pchUsage,
const QString &clangVersion,
const QString &clangResourceDirectory)
{ {
if (projectPart) { #ifndef UNIT_TESTS
ClangCompilerOptionsBuilder builder(*projectPart, clangVersion, clangResourceDirectory); return Core::ICore::instance()->libexecPath();
#else
builder.addWordWidth(); return QString();
builder.addTargetTriple(); #endif
builder.addLanguageOption(fileKind); }
builder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
builder.enableExceptions();
builder.addDefineToAvoidIncludingGccOrMinGwIntrinsics(); QStringList ClangCompilerOptionsBuilder::build(CppTools::ProjectFile::Kind fileKind,
builder.addDefineFloat128ForMingw(); PchUsage pchUsage)
builder.addToolchainAndProjectDefines(); {
builder.undefineCppLanguageFeatureMacrosForMsvc2015(); addWordWidth();
addTargetTriple();
addLanguageOption(fileKind);
addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
enableExceptions();
builder.addPredefinedMacrosAndHeaderPathsOptions(); addDefineFloat128ForMingw();
builder.addWrappedQtHeadersIncludePath(); addToolchainAndProjectMacros();
builder.addPrecompiledHeaderOptions(pchUsage); undefineClangVersionMacrosForMsvc();
builder.addHeaderPathOptions(); undefineCppLanguageFeatureMacrosForMsvc2015();
builder.addProjectConfigFileInclude();
builder.addMsvcCompatibilityVersion(); addPredefinedHeaderPathsOptions();
addWrappedQtHeadersIncludePath();
addPrecompiledHeaderOptions(pchUsage);
addHeaderPathOptions();
addProjectConfigFileInclude();
builder.addExtraOptions(); addMsvcCompatibilityVersion();
return builder.options(); addExtraOptions();
}
return QStringList(); return options();
} }
ClangCompilerOptionsBuilder::ClangCompilerOptionsBuilder(const CppTools::ProjectPart &projectPart, ClangCompilerOptionsBuilder::ClangCompilerOptionsBuilder(const CppTools::ProjectPart &projectPart,
...@@ -91,47 +90,35 @@ ClangCompilerOptionsBuilder::ClangCompilerOptionsBuilder(const CppTools::Project ...@@ -91,47 +90,35 @@ ClangCompilerOptionsBuilder::ClangCompilerOptionsBuilder(const CppTools::Project
bool ClangCompilerOptionsBuilder::excludeHeaderPath(const QString &path) const bool ClangCompilerOptionsBuilder::excludeHeaderPath(const QString &path) const
{ {
if (m_projectPart.toolchainType == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID) { if (m_projectPart.toolchainType == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID
if (path.contains("lib/gcc/i686-apple-darwin")) && path.contains("lib/gcc/i686-apple-darwin")) {
return true; return true;
} }
return CompilerOptionsBuilder::excludeHeaderPath(path); return CompilerOptionsBuilder::excludeHeaderPath(path);
} }
void ClangCompilerOptionsBuilder::addPredefinedMacrosAndHeaderPathsOptions() void ClangCompilerOptionsBuilder::addPredefinedHeaderPathsOptions()
{ {
if (m_projectPart.toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
addPredefinedMacrosAndHeaderPathsOptionsForMsvc();
else
addPredefinedMacrosAndHeaderPathsOptionsForNonMsvc();
}
void ClangCompilerOptionsBuilder::addPredefinedMacrosAndHeaderPathsOptionsForMsvc()
{
add("-nostdinc");
add("-undef"); add("-undef");
} add("-nostdinc");
add("-nostdlibinc");
void ClangCompilerOptionsBuilder::addPredefinedMacrosAndHeaderPathsOptionsForNonMsvc() if (m_projectPart.toolchainType != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
{ add(includeDirOption() + clangIncludeDirectory());
static const QString resourceDir = clangIncludeDirectory();
if (QTC_GUARD(!resourceDir.isEmpty())) {
add("-nostdlibinc");
add("-I" + QDir::toNativeSeparators(resourceDir));
add("-undef");
}
} }
void ClangCompilerOptionsBuilder::addWrappedQtHeadersIncludePath() void ClangCompilerOptionsBuilder::addWrappedQtHeadersIncludePath()
{ {
static const QString wrappedQtHeadersPath = creatorResourcePath() static const QString resourcePath = creatorResourcePath();
+ "/cplusplus/wrappedQtHeaders"; static QString wrappedQtHeadersPath = resourcePath + "/cplusplus/wrappedQtHeaders";
QDir dir(wrappedQtHeadersPath);
QTC_ASSERT(QDir(wrappedQtHeadersPath).exists(), return;);
if (m_projectPart.qtVersion != CppTools::ProjectPart::NoQt) { if (m_projectPart.qtVersion != CppTools::ProjectPart::NoQt) {
const QString wrappedQtCoreHeaderPath = wrappedQtHeadersPath + "/QtCore"; const QString wrappedQtCoreHeaderPath = wrappedQtHeadersPath + "/QtCore";
add("-I" + QDir::toNativeSeparators(wrappedQtHeadersPath)); add(includeDirOption() + QDir::toNativeSeparators(wrappedQtHeadersPath));
add("-I" + QDir::toNativeSeparators(wrappedQtCoreHeaderPath)); add(includeDirOption() + QDir::toNativeSeparators(wrappedQtCoreHeaderPath));
} }
} }
...@@ -154,12 +141,26 @@ void ClangCompilerOptionsBuilder::addExtraOptions() ...@@ -154,12 +141,26 @@ void ClangCompilerOptionsBuilder::addExtraOptions()
QString ClangCompilerOptionsBuilder::clangIncludeDirectory() const QString ClangCompilerOptionsBuilder::clangIncludeDirectory() const
{ {
QDir dir(creatorResourcePath() + "/clang/lib/clang/" + m_clangVersion + "/include"); QDir dir(creatorLibexecPath() + "/clang/lib/clang/" + m_clangVersion + "/include");
if (!dir.exists() || !QFileInfo(dir, "stdint.h").exists()) if (!dir.exists() || !QFileInfo(dir, "stdint.h").exists())
dir = QDir(m_clangResourceDirectory); dir = QDir(m_clangResourceDirectory);
return QDir::toNativeSeparators(dir.canonicalPath());
}
return dir.canonicalPath(); void ClangCompilerOptionsBuilder::undefineClangVersionMacrosForMsvc()
{
if (m_projectPart.toolchainType == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID) {
static QStringList macroNames {
"__clang__",
"__clang_major__",
"__clang_minor__",
"__clang_patchlevel__",
"__clang_version__"
};
foreach (const QString &macroName, macroNames)
add(undefineOption() + macroName);
}
} }
} // namespace CppTools } // namespace CppTools
...@@ -34,33 +34,24 @@ namespace CppTools { ...@@ -34,33 +34,24 @@ namespace CppTools {
class CPPTOOLS_EXPORT ClangCompilerOptionsBuilder : public CompilerOptionsBuilder class CPPTOOLS_EXPORT ClangCompilerOptionsBuilder : public CompilerOptionsBuilder
{ {
public: public:
static QStringList build(const ProjectPart *projectPart, QStringList build(ProjectFile::Kind fileKind,
ProjectFile::Kind fileKind, PchUsage pchUsage);
PchUsage pchUsage,
const QString &clangVersion,
const QString &clangResourceDirectory);
ClangCompilerOptionsBuilder(const ProjectPart &projectPart, ClangCompilerOptionsBuilder(const ProjectPart &projectPart,
const QString &clangVersion, const QString &clangVersion = QString(),
const QString &clangResourceDirectory); const QString &clangResourceDirectory = QString());
bool excludeHeaderPath(const QString &path) const override; virtual void addPredefinedHeaderPathsOptions();
virtual void addExtraOptions();
void addPredefinedMacrosAndHeaderPathsOptions();
void addPredefinedMacrosAndHeaderPathsOptionsForMsvc();
void addPredefinedMacrosAndHeaderPathsOptionsForNonMsvc();
void addWrappedQtHeadersIncludePath(); bool excludeHeaderPath(const QString &path) const override;
virtual void addWrappedQtHeadersIncludePath();
void addProjectConfigFileInclude(); void addProjectConfigFileInclude();
void addExtraOptions(); void undefineClangVersionMacrosForMsvc();
private: private:
QString clangIncludeDirectory() const; QString clangIncludeDirectory() const;
private:
QString m_clangVersion; QString m_clangVersion;
QString m_clangResourceDirectory; QString m_clangResourceDirectory;
}; };
......
...@@ -125,7 +125,7 @@ void CompilerOptionsBuilder::addPrecompiledHeaderOptions(PchUsage pchUsage) ...@@ -125,7 +125,7 @@ void CompilerOptionsBuilder::addPrecompiledHeaderOptions(PchUsage pchUsage)
m_options.append(result); m_options.append(result);
} }
void CompilerOptionsBuilder::addToolchainAndProjectDefines() void CompilerOptionsBuilder::addToolchainAndProjectMacros()
{ {
addMacros(m_projectPart.toolChainMacros); addMacros(m_projectPart.toolChainMacros);
addMacros(m_projectPart.projectMacros); addMacros(m_projectPart.projectMacros);
...@@ -258,21 +258,6 @@ void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtension ...@@ -258,21 +258,6 @@ void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtension
m_options.append(opts); m_options.append(opts);
} }
void CompilerOptionsBuilder::addDefineToAvoidIncludingGccOrMinGwIntrinsics()
{
// In gcc headers, lots of built-ins are referenced that clang does not understand.
// 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
// case.
const Core::Id type = m_projectPart.toolchainType;
if (type == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID
|| type == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID) {
addDefine({"_X86INTRIN_H_INCLUDED"});
addDefine({"BOOST_UUID_NO_SIMD"});
}
}
static QByteArray toMsCompatibilityVersionFormat(const QByteArray &mscFullVer) static QByteArray toMsCompatibilityVersionFormat(const QByteArray &mscFullVer)
{ {
return mscFullVer.left(2) return mscFullVer.left(2)
......
...@@ -54,13 +54,11 @@ public: ...@@ -54,13 +54,11 @@ public:
virtual void enableExceptions(); virtual void enableExceptions();
void addHeaderPathOptions(); void addHeaderPathOptions();
void addPrecompiledHeaderOptions(PchUsage pchUsage); void addPrecompiledHeaderOptions(PchUsage pchUsage);
void addToolchainAndProjectDefines(); void addToolchainAndProjectMacros();
void addMacros(const ProjectExplorer::Macros &macros); void addMacros(const ProjectExplorer::Macros &macros);
virtual void addLanguageOption(ProjectFile::Kind fileKind); virtual void addLanguageOption(ProjectFile::Kind fileKind);
virtual void addOptionsForLanguage(bool checkForBorlandExtensions = true); virtual void addOptionsForLanguage(bool checkForBorlandExtensions = true);
void addDefineToAvoidIncludingGccOrMinGwIntrinsics();
void addMsvcCompatibilityVersion(); void addMsvcCompatibilityVersion();
void undefineCppLanguageFeatureMacrosForMsvc2015(); void undefineCppLanguageFeatureMacrosForMsvc2015();
......
...@@ -129,12 +129,12 @@ void RefactoringEngine::SetUp() ...@@ -129,12 +129,12 @@ void RefactoringEngine::SetUp()
projectPart = CppTools::ProjectPart::Ptr(new CppTools::ProjectPart); projectPart = CppTools::ProjectPart::Ptr(new CppTools::ProjectPart);
projectPart->files.push_back(projectFile); projectPart->files.push_back(projectFile);
commandLine = Utils::SmallStringVector(ClangCompilerOptionsBuilder::build( ClangCompilerOptionsBuilder clangCOBuilder(*projectPart,
projectPart.data(),
projectFile.kind,
CppTools::CompilerOptionsBuilder::PchUsage::None,
CLANG_VERSION, CLANG_VERSION,
CLANG_RESOURCE_DIR)); CLANG_RESOURCE_DIR);
commandLine = Utils::SmallStringVector(clangCOBuilder.build(
projectFile.kind,
CppTools::CompilerOptionsBuilder::PchUsage::None));
commandLine.push_back(qStringFilePath); commandLine.push_back(qStringFilePath);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment