r272424 - Driver: make it easier to select the SjLj EH model

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 13:12:00 PDT 2016


Author: compnerd
Date: Fri Jun 10 15:12:00 2016
New Revision: 272424

URL: http://llvm.org/viewvc/llvm-project?rev=272424&view=rev
Log:
Driver: make it easier to select the SjLj EH model

GCC still permits enabling the SjLj EH model.  This is something which can be
done on various targets.  Hoist the -fsjlj-exceptions option into the driver and
pass it through.  This allows one to opt into the alternative EH model while
retaining the default to be the target's default.

Resolves PR27749!

Added:
    cfe/trunk/test/Driver/fsjlj-exceptions.c
Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=272424&r1=272423&r2=272424&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jun 10 15:12:00 2016
@@ -527,8 +527,6 @@ def fblocks_runtime_optional : Flag<["-"
   HelpText<"Weakly link in the blocks runtime">;
 def fexternc_nounwind : Flag<["-"], "fexternc-nounwind">,
   HelpText<"Assume all functions with C linkage do not unwind">;
-def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">,
-  HelpText<"Use SjLj style exceptions">;
 def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
   HelpText<"File name to use for split dwarf debug info output">;
 def fno_wchar : Flag<["-"], "fno-wchar">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=272424&r1=272423&r2=272424&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Jun 10 15:12:00 2016
@@ -584,6 +584,8 @@ def fencoding_EQ : Joined<["-"], "fencod
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group<f_Group>, Flags<[CoreOption]>;
 def fexceptions : Flag<["-"], "fexceptions">, Group<f_Group>, Flags<[CC1Option]>,
   HelpText<"Enable support for exception handling">;
+def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">, Group<f_Group>,
+  Flags<[CC1Option]>, HelpText<"Use SjLj style exceptions">;
 def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">,
     Group<clang_ignored_gcc_optimization_f_Group>;
 def : Flag<["-"], "fexpensive-optimizations">, Group<clang_ignored_gcc_optimization_f_Group>;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=272424&r1=272423&r2=272424&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jun 10 15:12:00 2016
@@ -5495,7 +5495,8 @@ void Clang::ConstructJob(Compilation &C,
     addExceptionArgs(Args, InputType, getToolChain(), KernelOrKext, objcRuntime,
                      CmdArgs);
 
-  if (getToolChain().UseSjLjExceptions(Args))
+  if (Args.hasArg(options::OPT_fsjlj_exceptions) ||
+      getToolChain().UseSjLjExceptions(Args))
     CmdArgs.push_back("-fsjlj-exceptions");
 
   // C++ "sane" operator new.

Added: cfe/trunk/test/Driver/fsjlj-exceptions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsjlj-exceptions.c?rev=272424&view=auto
==============================================================================
--- cfe/trunk/test/Driver/fsjlj-exceptions.c (added)
+++ cfe/trunk/test/Driver/fsjlj-exceptions.c Fri Jun 10 15:12:00 2016
@@ -0,0 +1,8 @@
+// RUN: %clang -target armv7-apple-ios -fexceptions -c %s -o /dev/null -### 2>&1 | FileCheck -check-prefix CHECK-IOS %s
+// RUN: %clang -target i686-windows-gnu -fexceptions -c %s -o /dev/null -### 2>&1 | FileCheck -check-prefix CHECK-MINGW-DEFAULT %s
+// RUN: %clang -target i686-windows-gnu -fexceptions -fsjlj-exceptions -c %s -o /dev/null -### 2>&1 | FileCheck -check-prefix CHECK-MINGW-SJLJ %s
+
+// CHECK-IOS: -fsjlj-exceptions
+// CHECK-MINGW-DEFAULT-NOT: -fsjlj-exceptions
+// CHECK-MINGW-SJLJ: -fsjlj-exceptions
+




More information about the cfe-commits mailing list