forked from qt-creator/qt-creator
Clang: Enable exceptions explicitly
For some reason, clang 3.8.0 on Windows does not enable exceptions anymore, which leads to parse errors in MSVC headers (reported upstream [1]). With this change, we can finally parse main/mainwindow.cpp of a Qt Widgets Application for a MSVC2015 Kit and libclang 3.8.0 without any error. [1] https://llvm.org/bugs/show_bug.cgi?id=27324 Change-Id: I532ad4852a06318baf083d363378bc577b3c4309 Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
This commit is contained in:
@@ -91,6 +91,7 @@ public:
|
|||||||
optionsBuilder.addTargetTriple();
|
optionsBuilder.addTargetTriple();
|
||||||
optionsBuilder.addLanguageOption(fileKind);
|
optionsBuilder.addLanguageOption(fileKind);
|
||||||
optionsBuilder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
|
optionsBuilder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
|
||||||
|
optionsBuilder.enableExceptions();
|
||||||
|
|
||||||
optionsBuilder.addToolchainAndProjectDefines();
|
optionsBuilder.addToolchainAndProjectDefines();
|
||||||
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
|
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||||
|
@@ -169,6 +169,7 @@ public:
|
|||||||
optionsBuilder.addTargetTriple();
|
optionsBuilder.addTargetTriple();
|
||||||
optionsBuilder.addLanguageOption(fileKind);
|
optionsBuilder.addLanguageOption(fileKind);
|
||||||
optionsBuilder.addOptionsForLanguage(false);
|
optionsBuilder.addOptionsForLanguage(false);
|
||||||
|
optionsBuilder.enableExceptions();
|
||||||
|
|
||||||
// In gcc headers, lots of built-ins are referenced that clang does not understand.
|
// 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
|
// Therefore, prevent the inclusion of the header that references them. Of course, this
|
||||||
@@ -184,9 +185,7 @@ public:
|
|||||||
optionsBuilder.addHeaderPathOptions();
|
optionsBuilder.addHeaderPathOptions();
|
||||||
optionsBuilder.addMsvcCompatibilityVersion();
|
optionsBuilder.addMsvcCompatibilityVersion();
|
||||||
|
|
||||||
if (type == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
|
if (type != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
|
||||||
optionsBuilder.add(QLatin1String("/EHsc")); // clang-cl does not understand exceptions
|
|
||||||
else
|
|
||||||
optionsBuilder.add(QLatin1String("-fPIC")); // TODO: Remove?
|
optionsBuilder.add(QLatin1String("-fPIC")); // TODO: Remove?
|
||||||
|
|
||||||
QStringList options = optionsBuilder.options();
|
QStringList options = optionsBuilder.options();
|
||||||
@@ -240,6 +239,14 @@ private:
|
|||||||
return CompilerOptionsBuilder::defineOption();
|
return CompilerOptionsBuilder::defineOption();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableExceptions() override
|
||||||
|
{
|
||||||
|
if (m_isMsvcToolchain)
|
||||||
|
add(QLatin1String("/EHsc"));
|
||||||
|
else
|
||||||
|
CompilerOptionsBuilder::enableExceptions();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_isMsvcToolchain;
|
bool m_isMsvcToolchain;
|
||||||
};
|
};
|
||||||
|
@@ -92,6 +92,12 @@ void CompilerOptionsBuilder::addTargetTriple()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CompilerOptionsBuilder::enableExceptions()
|
||||||
|
{
|
||||||
|
add(QLatin1String("-fcxx-exceptions"));
|
||||||
|
add(QLatin1String("-fexceptions"));
|
||||||
|
}
|
||||||
|
|
||||||
void CompilerOptionsBuilder::addHeaderPathOptions()
|
void CompilerOptionsBuilder::addHeaderPathOptions()
|
||||||
{
|
{
|
||||||
typedef ProjectPartHeaderPath HeaderPath;
|
typedef ProjectPartHeaderPath HeaderPath;
|
||||||
|
@@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
// Add options based on project part
|
// Add options based on project part
|
||||||
virtual void addTargetTriple();
|
virtual void addTargetTriple();
|
||||||
|
virtual void enableExceptions();
|
||||||
void addHeaderPathOptions();
|
void addHeaderPathOptions();
|
||||||
void addToolchainAndProjectDefines();
|
void addToolchainAndProjectDefines();
|
||||||
virtual void addLanguageOption(ProjectFile::Kind fileKind);
|
virtual void addLanguageOption(ProjectFile::Kind fileKind);
|
||||||
|
Reference in New Issue
Block a user