[cfe-commits] r83199 - in /cfe/trunk/lib: Driver/Tools.cpp Frontend/InitPreprocessor.cpp
Rafael Espindola
rafael.espindola at gmail.com
Thu Oct 1 06:33:34 PDT 2009
Author: rafael
Date: Thu Oct 1 08:33:33 2009
New Revision: 83199
URL: http://llvm.org/viewvc/llvm-project?rev=83199&view=rev
Log:
Move the "needs exception support" logic to clang. This also fixes
-fno-exceptions in C++ code. We used to always define __EXCEPTIONS in
C++.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=83199&r1=83198&r2=83199&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Oct 1 08:33:33 2009
@@ -472,6 +472,31 @@
}
}
+static bool needsExceptions(const ArgList &Args, types::ID InputType) {
+ if (Arg *A = Args.getLastArg(options::OPT_fexceptions,
+ options::OPT_fno_exceptions)) {
+ if (A->getOption().matches(options::OPT_fexceptions))
+ return true;
+ else
+ return false;
+ }
+ switch (InputType) {
+ case types::TY_CXX: case types::TY_CXXHeader:
+ case types::TY_PP_CXX: case types::TY_PP_CXXHeader:
+ case types::TY_ObjCXX: case types::TY_ObjCXXHeader:
+ case types::TY_PP_ObjCXX: case types::TY_PP_ObjCXXHeader:
+ return true;
+ case types::TY_ObjC: case types::TY_ObjCHeader:
+ case types::TY_PP_ObjC: case types::TY_PP_ObjCHeader:
+ if (Args.hasArg(options::OPT_fobjc_nonfragile_abi))
+ return true;
+ else
+ return false;
+ default:
+ return false;
+ }
+}
+
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Job &Dest,
const InputInfo &Output,
@@ -808,15 +833,10 @@
CmdArgs.push_back("-fblocks=0");
}
- // -fexceptions default varies depending on platform and language; only
- // pass if specified.
- if (Arg *A = Args.getLastArg(options::OPT_fexceptions,
- options::OPT_fno_exceptions)) {
- if (A->getOption().matches(options::OPT_fexceptions))
- CmdArgs.push_back("-fexceptions");
- else
- CmdArgs.push_back("-fexceptions=0");
- }
+ if (needsExceptions(Args, InputType))
+ CmdArgs.push_back("-fexceptions");
+ else
+ CmdArgs.push_back("-fexceptions=0");
// -frtti is default, only pass non-default.
if (!Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti))
Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=83199&r1=83198&r2=83199&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Thu Oct 1 08:33:33 2009
@@ -274,7 +274,6 @@
if (LangOpts.ObjCNonFragileABI) {
DefineBuiltinMacro(Buf, "__OBJC2__=1");
DefineBuiltinMacro(Buf, "OBJC_ZEROCOST_EXCEPTIONS=1");
- DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
}
if (LangOpts.getGCMode() != LangOptions::NonGC)
@@ -299,9 +298,11 @@
DefineBuiltinMacro(Buf, "__BLOCKS__=1");
}
+ if (LangOpts.Exceptions)
+ DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
+
if (LangOpts.CPlusPlus) {
DefineBuiltinMacro(Buf, "__DEPRECATED=1");
- DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
DefineBuiltinMacro(Buf, "__GNUG__=4");
DefineBuiltinMacro(Buf, "__GXX_WEAK__=1");
if (LangOpts.GNUMode)
More information about the cfe-commits
mailing list