forked from qt-creator/qt-creator
Clang: Avoid running into gcc/mingw intrinsics
Same as for the Clang Static Analyzer, so move the implementation into the base class and use it. This has gone unnoticed so far because it looks like that the error diagnostic from the bug report can be extracted with libclang (as shown in the info bar), but is not printed from libclang or clang.exe itself. Change-Id: I5b714ba374c5fdefe234faf012a3515e96c9a08c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -95,6 +95,7 @@ public:
|
||||
optionsBuilder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
|
||||
optionsBuilder.enableExceptions();
|
||||
|
||||
optionsBuilder.addDefineToAvoidIncludingGccOrMinGwIntrinsics();
|
||||
optionsBuilder.addToolchainAndProjectDefines();
|
||||
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
|
||||
|
@@ -130,6 +130,7 @@ Utils::SmallStringVector RefactoringCompilerOptionsBuilder::build(CppTools::Proj
|
||||
optionsBuilder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
|
||||
optionsBuilder.enableExceptions();
|
||||
|
||||
optionsBuilder.addDefineToAvoidIncludingGccOrMinGwIntrinsics();
|
||||
optionsBuilder.addToolchainAndProjectDefines();
|
||||
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
|
||||
|
@@ -175,15 +175,8 @@ public:
|
||||
optionsBuilder.addOptionsForLanguage(false);
|
||||
optionsBuilder.enableExceptions();
|
||||
|
||||
// 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.
|
||||
optionsBuilder.addDefineToAvoidIncludingGccOrMinGwIntrinsics();
|
||||
const Core::Id type = projectPart.toolchainType;
|
||||
if (type == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID
|
||||
|| type == ProjectExplorer::Constants::GCC_TOOLCHAIN_TYPEID)
|
||||
optionsBuilder.addDefine("#define _X86INTRIN_H_INCLUDED");
|
||||
|
||||
if (type != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
|
||||
optionsBuilder.addDefines(projectPart.toolchainDefines);
|
||||
optionsBuilder.addDefines(projectPart.projectDefines);
|
||||
|
@@ -270,6 +270,20 @@ void CompilerOptionsBuilder::addOptionsForLanguage(bool checkForBorlandExtension
|
||||
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("#define _X86INTRIN_H_INCLUDED");
|
||||
}
|
||||
}
|
||||
|
||||
static QByteArray toMsCompatibilityVersionFormat(const QByteArray &mscFullVer)
|
||||
{
|
||||
return mscFullVer.left(2)
|
||||
|
@@ -53,6 +53,8 @@ public:
|
||||
virtual void addLanguageOption(ProjectFile::Kind fileKind);
|
||||
virtual void addOptionsForLanguage(bool checkForBorlandExtensions = true);
|
||||
|
||||
void addDefineToAvoidIncludingGccOrMinGwIntrinsics();
|
||||
|
||||
void addMsvcCompatibilityVersion();
|
||||
void undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
|
||||
|
Reference in New Issue
Block a user