[PATCH] D91894: [lld-macho] Implement -fatal_warnings

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 13:45:40 PST 2020


thakis created this revision.
thakis added a reviewer: int3.
Herald added a subscriber: dang.
thakis requested review of this revision.

https://reviews.llvm.org/D91894

Files:
  lld/MachO/DriverUtils.cpp
  lld/MachO/Options.td
  lld/test/MachO/fatal-warnings.s


Index: lld/test/MachO/fatal-warnings.s
===================================================================
--- /dev/null
+++ lld/test/MachO/fatal-warnings.s
@@ -0,0 +1,13 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t1.o
+
+# RUN: %lld %t1.o -o /dev/null -single_module 2>&1 \
+# RUN:     | FileCheck -check-prefix=WARNING %s
+# RUN: not %lld %t1.o -fatal_warnings -o /dev/null -single_module 2>&1 \
+# RUN:     | FileCheck -check-prefix=ERROR %s
+
+# ERROR: error: Option `-single_module' is deprecated
+# WARNING: warning: Option `-single_module' is deprecated
+
+.globl _main
+_main:
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -606,9 +606,7 @@
      Flags<[HelpHidden]>,
      Group<grp_rare>;
 def fatal_warnings : Flag<["-"], "fatal_warnings">,
-     HelpText<"Escalate warnings as errors">,
-     Flags<[HelpHidden]>,
-     Group<grp_rare>;
+     HelpText<"Treat warnings as errors">;
 def no_eh_labels : Flag<["-"], "no_eh_labels">,
      HelpText<"In -r mode, suppress .eh labels in the __eh_frame section">,
      Flags<[HelpHidden]>,
Index: lld/MachO/DriverUtils.cpp
===================================================================
--- lld/MachO/DriverUtils.cpp
+++ lld/MachO/DriverUtils.cpp
@@ -70,6 +70,10 @@
 
   opt::InputArgList args = ParseArgs(vec, missingIndex, missingCount);
 
+  // Handle -fatal_warnings early since it converts missing argument warnings
+  // to errors.
+  errorHandler().fatalWarnings = args.hasArg(OPT_fatal_warnings);
+
   if (missingCount)
     error(Twine(args.getArgString(missingIndex)) + ": missing argument");
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91894.306774.patch
Type: text/x-patch
Size: 1709 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201120/bb408521/attachment.bin>


More information about the llvm-commits mailing list