ClangStaticAnalyzer: Fix analyzing qbs projects on macOS

The system clang on macOS is aware of the header paths, but not our
shipped clang.

Task-number: QTCREATORBUG-15869
Change-Id: Iabb56d9443808be2822a21b48bb111a6a8a8c604
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Nikolai Kosjar
2016-07-12 16:27:15 +02:00
parent 498934cfe8
commit 580c7606c4

View File

@@ -53,6 +53,7 @@
#include <projectexplorer/toolchain.h> #include <projectexplorer/toolchain.h>
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/hostosinfo.h>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QTemporaryDir> #include <QTemporaryDir>
@@ -300,6 +301,20 @@ static QStringList createOptionsToUndefineClangVersionMacrosForMsvc(const Projec
return optionsBuilder.options(); return optionsBuilder.options();
} }
static QStringList createHeaderPathsOptionsForClangOnMac(const ProjectPart &projectPart)
{
QStringList options;
if (Utils::HostOsInfo::isMacHost()
&& projectPart.toolchainType == ProjectExplorer::Constants::CLANG_TOOLCHAIN_TYPEID) {
ClangStaticAnalyzerOptionsBuilder optionsBuilder(projectPart);
optionsBuilder.addHeaderPathOptions();
options = optionsBuilder.options();
}
return options;
}
static QStringList tweakedArguments(const ProjectPart &projectPart, static QStringList tweakedArguments(const ProjectPart &projectPart,
const QString &filePath, const QString &filePath,
const QStringList &arguments, const QStringList &arguments,
@@ -308,6 +323,7 @@ static QStringList tweakedArguments(const ProjectPart &projectPart,
QStringList newArguments = inputAndOutputArgumentsRemoved(filePath, arguments); QStringList newArguments = inputAndOutputArgumentsRemoved(filePath, arguments);
prependWordWidthArgumentIfNotIncluded(&newArguments, extraParams.wordWidth); prependWordWidthArgumentIfNotIncluded(&newArguments, extraParams.wordWidth);
prependTargetTripleIfNotIncludedAndNotEmpty(&newArguments, extraParams.targetTriple); prependTargetTripleIfNotIncludedAndNotEmpty(&newArguments, extraParams.targetTriple);
newArguments.append(createHeaderPathsOptionsForClangOnMac(projectPart));
newArguments.append(createMsCompatibilityVersionOption(projectPart)); newArguments.append(createMsCompatibilityVersionOption(projectPart));
newArguments.append(createOptionsToUndefineClangVersionMacrosForMsvc(projectPart)); newArguments.append(createOptionsToUndefineClangVersionMacrosForMsvc(projectPart));
newArguments.append(createOptionsToUndefineCppLanguageFeatureMacrosForMsvc2015(projectPart)); newArguments.append(createOptionsToUndefineCppLanguageFeatureMacrosForMsvc2015(projectPart));