forked from qt-creator/qt-creator
Clang: Undefine language features as fix for MSVC2015/clang-3.8.0
This applies the following change for the clang code model, too.
commit d13d179524
Clang Static Analyzer: Workaround analyzing MSVC2015 projects with clang 3.8.0 II
Change-Id: Ia229d7e8b24c2e1c0a83d9a53c623ea1f79c4a06
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -82,9 +82,7 @@ ClangStaticAnalyzerRunControl::ClangStaticAnalyzerRunControl(
|
||||
|
||||
ToolChain *toolChain = ToolChainKitInformation::toolChain(target->kit());
|
||||
QTC_ASSERT(toolChain, return);
|
||||
Abi abi = runConfiguration->abi();
|
||||
m_extraToolChainInfo.wordWidth = abi.wordWidth();
|
||||
m_extraToolChainInfo.isMsvc2015 = abi.osFlavor() == Abi::WindowsMsvc2015Flavor;
|
||||
m_extraToolChainInfo.wordWidth = runConfiguration->abi().wordWidth();
|
||||
m_extraToolChainInfo.targetTriple = toolChain->originalTargetTriple();
|
||||
}
|
||||
|
||||
@@ -142,54 +140,6 @@ QStringList inputAndOutputArgumentsRemoved(const QString &inputFile, const QStri
|
||||
return newArguments;
|
||||
}
|
||||
|
||||
static QStringList languageFeatureMacros()
|
||||
{
|
||||
// Collected with:
|
||||
// $ CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
|
||||
// $ D:\usr\llvm-3.8.0\bin\clang++.exe -fms-compatibility-version=19 -std=c++1y -dM -E D:\empty.cpp | grep __cpp_
|
||||
static QStringList macros {
|
||||
QLatin1String("__cpp_aggregate_nsdmi"),
|
||||
QLatin1String("__cpp_alias_templates"),
|
||||
QLatin1String("__cpp_attributes"),
|
||||
QLatin1String("__cpp_binary_literals"),
|
||||
QLatin1String("__cpp_constexpr"),
|
||||
QLatin1String("__cpp_decltype"),
|
||||
QLatin1String("__cpp_decltype_auto"),
|
||||
QLatin1String("__cpp_delegating_constructors"),
|
||||
QLatin1String("__cpp_digit_separators"),
|
||||
QLatin1String("__cpp_generic_lambdas"),
|
||||
QLatin1String("__cpp_inheriting_constructors"),
|
||||
QLatin1String("__cpp_init_captures"),
|
||||
QLatin1String("__cpp_initializer_lists"),
|
||||
QLatin1String("__cpp_lambdas"),
|
||||
QLatin1String("__cpp_nsdmi"),
|
||||
QLatin1String("__cpp_range_based_for"),
|
||||
QLatin1String("__cpp_raw_strings"),
|
||||
QLatin1String("__cpp_ref_qualifiers"),
|
||||
QLatin1String("__cpp_return_type_deduction"),
|
||||
QLatin1String("__cpp_rtti"),
|
||||
QLatin1String("__cpp_rvalue_references"),
|
||||
QLatin1String("__cpp_static_assert"),
|
||||
QLatin1String("__cpp_unicode_characters"),
|
||||
QLatin1String("__cpp_unicode_literals"),
|
||||
QLatin1String("__cpp_user_defined_literals"),
|
||||
QLatin1String("__cpp_variable_templates"),
|
||||
QLatin1String("__cpp_variadic_templates"),
|
||||
};
|
||||
|
||||
return macros;
|
||||
}
|
||||
|
||||
static void undefineCppLanguageFeatureMacrosForMsvc2015(QStringList *arguments, bool isMsvc2015)
|
||||
{
|
||||
QTC_ASSERT(arguments, return);
|
||||
|
||||
if (isMsvc2015) {
|
||||
foreach (const QString ¯oName, languageFeatureMacros())
|
||||
arguments->append(QLatin1String("/U") + macroName);
|
||||
}
|
||||
}
|
||||
|
||||
static QString createLanguageOptionMsvc(ProjectFile::Kind fileKind)
|
||||
{
|
||||
switch (fileKind) {
|
||||
@@ -230,6 +180,7 @@ public:
|
||||
optionsBuilder.addDefine("#define _X86INTRIN_H_INCLUDED\n");
|
||||
|
||||
optionsBuilder.addToolchainAndProjectDefines();
|
||||
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
optionsBuilder.addHeaderPathOptions();
|
||||
optionsBuilder.addMsvcCompatibilityVersion();
|
||||
|
||||
@@ -240,7 +191,6 @@ public:
|
||||
|
||||
QStringList options = optionsBuilder.options();
|
||||
prependWordWidthArgumentIfNotIncluded(&options, extraParams.wordWidth);
|
||||
undefineCppLanguageFeatureMacrosForMsvc2015(&options, extraParams.isMsvc2015);
|
||||
|
||||
return options;
|
||||
}
|
||||
@@ -303,6 +253,15 @@ static QStringList createMsCompatibilityVersionOption(const ProjectPart &project
|
||||
return option;
|
||||
}
|
||||
|
||||
static QStringList createOptionsToUndefineCppLanguageFeatureMacrosForMsvc2015(
|
||||
const ProjectPart &projectPart)
|
||||
{
|
||||
ClangStaticAnalyzerOptionsBuilder optionsBuilder(projectPart);
|
||||
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
|
||||
return optionsBuilder.options();
|
||||
}
|
||||
|
||||
static QStringList tweakedArguments(const ProjectPart &projectPart,
|
||||
const QString &filePath,
|
||||
const QStringList &arguments,
|
||||
@@ -312,7 +271,7 @@ static QStringList tweakedArguments(const ProjectPart &projectPart,
|
||||
prependWordWidthArgumentIfNotIncluded(&newArguments, extraParams.wordWidth);
|
||||
prependTargetTripleIfNotIncludedAndNotEmpty(&newArguments, extraParams.targetTriple);
|
||||
newArguments.append(createMsCompatibilityVersionOption(projectPart));
|
||||
undefineCppLanguageFeatureMacrosForMsvc2015(&newArguments, extraParams.isMsvc2015);
|
||||
newArguments.append(createOptionsToUndefineCppLanguageFeatureMacrosForMsvc2015(projectPart));
|
||||
|
||||
return newArguments;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user