Clang: Explicitly set the target triple

As for the analyzer, this makes us independent of the default triple and will
most likely reduce the maintenance - e.g. the target implies certain internal
command line arguments, we will profit from added ones.

This fixes parsing of mingw headers with the clang code model.

Change-Id: I722b981125a80fac5f62a7af40a83ecdd7bbf811
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2016-04-08 14:19:23 +02:00
parent 0235412b34
commit 276f4c489c
6 changed files with 40 additions and 1 deletions

View File

@@ -236,6 +236,8 @@ public:
const ExtraToolChainInfo &extraParams)
{
ClangStaticAnalyzerOptionsBuilder optionsBuilder(projectPart);
optionsBuilder.addTargetTriple();
optionsBuilder.addLanguageOption(fileKind);
optionsBuilder.addOptionsForLanguage(false);
@@ -258,7 +260,6 @@ public:
QStringList options = optionsBuilder.options();
prependWordWidthArgumentIfNotIncluded(&options, extraParams.wordWidth);
prependTargetTripleIfNotIncludedAndNotEmpty(&options, extraParams.targetTriple);
appendMsCompatibility2015OptionForMsvc2015(&options, extraParams.isMsvc2015);
undefineCppLanguageFeatureMacrosForMsvc2015(&options, extraParams.isMsvc2015);
@@ -272,6 +273,15 @@ private:
{
}
void addTargetTriple() override
{
// For MSVC toolchains we use clang-cl.exe, so there is nothing to do here since
// 1) clang-cl.exe does not understand the "-triple" option
// 2) clang-cl.exe already hardcodes the right triple value (even if built with mingw)
if (m_projectPart.toolchainType != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
CompilerOptionsBuilder::addTargetTriple();
}
void addLanguageOption(ProjectFile::Kind fileKind) override
{
if (m_isMsvcToolchain)