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 committed May 26, 2022
1 parent 35b0955 commit 966427b
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
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
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 966427b

Please sign in to comment.