[lld] 966427b - [lld][WebAssemlby] Check for command line flags with missing arguments

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 13:35:51 PDT 2022


Author: Sam Clegg
Date: 2022-05-26T13:35:27-07:00
New Revision: 966427b8471d204b3df1412041af9aa9702db869

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

LOG: [lld][WebAssemlby] Check for command line flags with missing arguments

I'm really not sure how this was overlooked when we first ported lld
to Wasm.  The upstream code in the ELF backend has these two lines but
for some reason they never make it into the Wasm version.

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

Added: 
    

Modified: 
    lld/test/wasm/driver.s
    lld/wasm/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/test/wasm/driver.s b/lld/test/wasm/driver.s
index 46d59e362a6a8..6247eda93b5ba 100644
--- a/lld/test/wasm/driver.s
+++ b/lld/test/wasm/driver.s
@@ -5,6 +5,9 @@ _start:
   .functype _start () -> ()
   end_function
 
+# RUN: not wasm-ld %t -o 2>&1 | FileCheck --check-prefix=NO_O_VAL %s
+# NO_O_VAL: error: -o: missing argument
+
 # RUN: not wasm-ld -o %t.exe 2>&1 | FileCheck -check-prefix=IN %s
 # IN: error: no input files
 

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 1dc6b9dd67aca..ca32d9a49da0b 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -184,6 +184,9 @@ opt::InputArgList WasmOptTable::parse(ArrayRef<const char *> argv) {
   args = this->ParseArgs(vec, missingIndex, missingCount);
 
   handleColorDiagnostics(args);
+  if (missingCount)
+    error(Twine(args.getArgString(missingIndex)) + ": missing argument");
+
   for (auto *arg : args.filtered(OPT_UNKNOWN))
     error("unknown argument: " + arg->getAsString(args));
   return args;


        


More information about the llvm-commits mailing list