[PATCH] D48688: Consistently bail out if we fail to parse command line args

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 17:18:32 PDT 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, aheejin, arichardson, emaste.
Herald added a reviewer: espindola.

Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D48688

Files:
  ELF/Driver.cpp
  wasm/Driver.cpp


Index: wasm/Driver.cpp
===================================================================
--- wasm/Driver.cpp
+++ wasm/Driver.cpp
@@ -293,6 +293,8 @@
 void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
   WasmOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
+  if (errorCount())
+    return;
 
   // Handle --help
   if (Args.hasArg(OPT_help)) {
@@ -425,8 +427,6 @@
   }
 
   createFiles(Args);
-  if (errorCount())
-    return;
 
   // Add all files to the symbol table. This will add almost all
   // symbols that we need to the symbol table.
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -328,6 +328,8 @@
 void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
+  if (errorCount())
+    return;
 
   // Interpret this flag early because error() depends on them.
   errorHandler().ErrorLimit = args::getInteger(Args, OPT_error_limit, 20);
@@ -1054,7 +1056,7 @@
     }
   }
 
-  if (Files.empty() && errorCount() == 0)
+  if (Files.empty())
     error("no input files");
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48688.153214.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180628/eff11468/attachment.bin>


More information about the llvm-commits mailing list