diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 22 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 6 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 10 |
3 files changed, 28 insertions, 10 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 408a870a74..cde71e7ed8 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -460,12 +460,32 @@ void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D, F->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv)); } +/// Determines whether the language options require us to model +/// unwind exceptions. We treat -fexceptions as mandating this +/// except under the fragile ObjC ABI with only ObjC exceptions +/// enabled. This means, for example, that C with -fexceptions +/// enables this. +static bool hasUnwindExceptions(const LangOptions &Features) { + // If exceptions are completely disabled, obviously this is false. + if (!Features.Exceptions) return false; + + // If C++ exceptions are enabled, this is true. + if (Features.CXXExceptions) return true; + + // If ObjC exceptions are enabled, this depends on the ABI. + if (Features.ObjCExceptions) { + if (!Features.ObjCNonFragileABI) return false; + } + + return true; +} + void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F) { if (CodeGenOpts.UnwindTables) F->setHasUWTable(); - if (!Features.Exceptions && !Features.ObjCNonFragileABI) + if (!hasUnwindExceptions(Features)) F->addFnAttr(llvm::Attribute::NoUnwind); if (D->hasAttr<NakedAttr>()) { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 936dee16c9..e193c0f505 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1965,9 +1965,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } - if (objcABIVersion == 2 || objcABIVersion == 3) { - CmdArgs.push_back("-fobjc-nonfragile-abi"); - + if (objcABIVersion == 1) { + CmdArgs.push_back("-fobjc-fragile-abi"); + } else { // -fobjc-dispatch-method is only relevant with the nonfragile-abi, and // legacy is the default. if (!Args.hasFlag(options::OPT_fobjc_legacy_dispatch, diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 671e3da295..5252ebadac 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -623,10 +623,8 @@ static void LangOptsToArgs(const LangOptions &Opts, Res.push_back("-fmsc-version=" + llvm::utostr(Opts.MSCVersion)); if (Opts.Borland) Res.push_back("-fborland-extensions"); - if (Opts.ObjCNonFragileABI) - Res.push_back("-fobjc-nonfragile-abi"); - if (Opts.ObjCNonFragileABI2) - Res.push_back("-fobjc-nonfragile-abi"); + if (!Opts.ObjCNonFragileABI) + Res.push_back("-fobjc-fragile-abi"); if (Opts.ObjCDefaultSynthProperties) Res.push_back("-fobjc-default-synthesize-properties"); // NoInline is implicit. @@ -1619,7 +1617,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.setGC(LangOptions::HybridGC); else if (Args.hasArg(OPT_fobjc_arc)) { Opts.ObjCAutoRefCount = 1; - if (!Args.hasArg(OPT_fobjc_nonfragile_abi)) + if (Args.hasArg(OPT_fobjc_fragile_abi)) Diags.Report(diag::err_arc_nonfragile_abi); } @@ -1723,7 +1721,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.NeXTRuntime = !Args.hasArg(OPT_fgnu_runtime); Opts.ObjCConstantStringClass = Args.getLastArgValue(OPT_fconstant_string_class); - Opts.ObjCNonFragileABI = Args.hasArg(OPT_fobjc_nonfragile_abi); + Opts.ObjCNonFragileABI = !Args.hasArg(OPT_fobjc_fragile_abi); if (Opts.ObjCNonFragileABI) Opts.ObjCNonFragileABI2 = true; Opts.ObjCDefaultSynthProperties = |