forked from OSchip/llvm-project
Move the "needs exception support" logic to clang. This also fixes
-fno-exceptions in C++ code. We used to always define __EXCEPTIONS in C++. llvm-svn: 83199
This commit is contained in:
parent
4fb2891396
commit
00a665751d
|
@ -472,6 +472,31 @@ void Clang::AddX86TargetArgs(const ArgList &Args,
|
|||
}
|
||||
}
|
||||
|
||||
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 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
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))
|
||||
|
|
|
@ -274,7 +274,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
|||
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 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue