[PATCH] D55446: Show "Unknown -z option" error message early.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 7 10:23:42 PST 2018


ruiu created this revision.
ruiu added a reviewer: grimar.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

Previously, we would show an error message for an unknown command line flag
(e.g. `--foo`) but we wouldn't show that for an unknown -z option (e.g. `-z foo`).
That's inconsistent. With this patch, we always show an error message for an
unknown -z option.


https://reviews.llvm.org/D55446

Files:
  lld/ELF/Driver.cpp
  lld/test/ELF/driver.test


Index: lld/test/ELF/driver.test
===================================================================
--- lld/test/ELF/driver.test
+++ lld/test/ELF/driver.test
@@ -60,6 +60,7 @@
 # ERR9: cannot open output file utput=/no/such/file
 
 # RUN: not ld.lld %t -z foo 2>&1 | FileCheck -check-prefix=ERR10 %s
+# RUN: not ld.lld %t -z foo --version 2>&1 | FileCheck -check-prefix=ERR10 %s
 # ERR10: unknown -z value: foo
 
 ## Check we report "unknown -z value" error even with -v.
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -368,6 +368,7 @@
 void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
+  checkZOptions(Args);
 
   // Interpret this flag early because error() depends on them.
   errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20);
@@ -413,7 +414,6 @@
   }
 
   readConfigs(Args);
-  checkZOptions(Args);
 
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55446.177248.patch
Type: text/x-patch
Size: 1133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/4e7ae69c/attachment.bin>


More information about the llvm-commits mailing list