Commit e2e3be09 authored by Nikolai Kosjar's avatar Nikolai Kosjar

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: default avatarChristian Kandeler <christian.kandeler@theqtcompany.com>
parent 266036fe
......@@ -91,6 +91,7 @@ public:
optionsBuilder.addTargetTriple();
optionsBuilder.addLanguageOption(fileKind);
optionsBuilder.addOptionsForLanguage(/*checkForBorlandExtensions*/ true);
optionsBuilder.enableExceptions();
optionsBuilder.addToolchainAndProjectDefines();
optionsBuilder.undefineCppLanguageFeatureMacrosForMsvc2015();
......
......@@ -169,6 +169,7 @@ public:
optionsBuilder.addTargetTriple();
optionsBuilder.addLanguageOption(fileKind);
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
......@@ -184,9 +185,7 @@ public:
optionsBuilder.addHeaderPathOptions();
optionsBuilder.addMsvcCompatibilityVersion();
if (type == ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
optionsBuilder.add(QLatin1String("/EHsc")); // clang-cl does not understand exceptions
else
if (type != ProjectExplorer::Constants::MSVC_TOOLCHAIN_TYPEID)
optionsBuilder.add(QLatin1String("-fPIC")); // TODO: Remove?
QStringList options = optionsBuilder.options();
......@@ -240,6 +239,14 @@ private:
return CompilerOptionsBuilder::defineOption();
}
void enableExceptions() override
{
if (m_isMsvcToolchain)
add(QLatin1String("/EHsc"));
else
CompilerOptionsBuilder::enableExceptions();
}
private:
bool m_isMsvcToolchain;
};
......
......@@ -92,6 +92,12 @@ void CompilerOptionsBuilder::addTargetTriple()
}
}
void CompilerOptionsBuilder::enableExceptions()
{
add(QLatin1String("-fcxx-exceptions"));
add(QLatin1String("-fexceptions"));
}
void CompilerOptionsBuilder::addHeaderPathOptions()
{
typedef ProjectPartHeaderPath HeaderPath;
......
......@@ -46,6 +46,7 @@ public:
// Add options based on project part
virtual void addTargetTriple();
virtual void enableExceptions();
void addHeaderPathOptions();
void addToolchainAndProjectDefines();
virtual void addLanguageOption(ProjectFile::Kind fileKind);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment