Re-land r228258 and make clang-cl's /EHs- disable -fexceptions again
After r228258, Clang started emitting C++ EH IR that LLVM wasn't ready
to deal with, even when exceptions were disabled with /EHs-. This time,
make /EHs- turn off -fexceptions while still emitting exceptional
constructs in functions using __try. Since Sema rejects C++ exception
handling constructs before CodeGen, landingpads should only appear in
such functions as the result of a __try.
llvm-svn: 228329
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index d24375b..8634ed6 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -4877,10 +4877,10 @@
const Driver &D = getToolChain().getDriver();
EHFlags EH = parseClangCLEHFlags(D, Args);
// FIXME: Do something with NoExceptC.
- if (EH.Synch || EH.Asynch)
+ if (EH.Synch || EH.Asynch) {
CmdArgs.push_back("-fcxx-exceptions");
- // Always add -fexceptions to allow SEH __try.
- CmdArgs.push_back("-fexceptions");
+ CmdArgs.push_back("-fexceptions");
+ }
// /EP should expand to -E -P.
if (Args.hasArg(options::OPT__SLASH_EP)) {