[llvm-branch-commits] [lld] c0e4020 - [lld-macho] Implement -fatal_warnings

Nico Weber via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 30 06:34:07 PST 2020


Author: Nico Weber
Date: 2020-11-30T09:29:21-05:00
New Revision: c0e4020c927134b1dfe4181f54147af95f482558

URL: https://github.com/llvm/llvm-project/commit/c0e4020c927134b1dfe4181f54147af95f482558
DIFF: https://github.com/llvm/llvm-project/commit/c0e4020c927134b1dfe4181f54147af95f482558.diff

LOG: [lld-macho] Implement -fatal_warnings

Differential Revision: https://reviews.llvm.org/D91894

Added: 
    lld/test/MachO/fatal-warnings.s

Modified: 
    lld/MachO/DriverUtils.cpp
    lld/MachO/Options.td

Removed: 
    


################################################################################
diff  --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp
index 90f1dd323f02..ec57c6898129 100644
--- a/lld/MachO/DriverUtils.cpp
+++ b/lld/MachO/DriverUtils.cpp
@@ -76,6 +76,10 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) {
   cl::ExpandResponseFiles(saver, cl::TokenizeGNUCommandLine, vec);
   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");
 

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index f36820b22b17..ed3d00452bd3 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -610,8 +610,7 @@ def no_application_extension : Flag<["-"], "no_application_extension">,
      Flags<[HelpHidden]>,
      Group<grp_rare>;
 def fatal_warnings : Flag<["-"], "fatal_warnings">,
-     HelpText<"Escalate warnings as errors">,
-     Flags<[HelpHidden]>,
+     HelpText<"Treat warnings as errors">,
      Group<grp_rare>;
 def no_eh_labels : Flag<["-"], "no_eh_labels">,
      HelpText<"In -r mode, suppress .eh labels in the __eh_frame section">,

diff  --git a/lld/test/MachO/fatal-warnings.s b/lld/test/MachO/fatal-warnings.s
new file mode 100644
index 000000000000..4ab5589cde08
--- /dev/null
+++ b/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:


        


More information about the llvm-branch-commits mailing list