Skip to content

Commit

Permalink
[lld][WebAssemlby] Check for command line flags with missing arguments
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbc100 authored and memfrob committed Oct 4, 2022
1 parent 0160542 commit 1b27e14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lld/test/wasm/driver.s
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1b27e14

Please sign in to comment.