[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
This commit is contained in:
Sam Clegg 2022-05-26 13:11:20 -07:00
parent 35b0955aa5
commit 966427b847
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -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;