diff options
author | Nico Weber <thakis@chromium.org> | 2020-11-23 10:51:56 -0500 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2020-11-24 11:33:39 -0500 |
commit | 11b76258331659daa57e15fe86c1f1234267a78d (patch) | |
tree | a81d7852243ccfe2e629839ed64596ccb135ef74 /lld/MachO | |
parent | b86a1cd2f8540b311b5b921235e612fea4134dff (diff) | |
download | llvm-project-11b76258331659daa57e15fe86c1f1234267a78d.tar.gz |
[lld/mac] Implement basic typo correction for flags
Also use "unknown flag 'flag'" instead of "unknown flag: flag" for
consistency with the other ports.
Differential Revision: https://reviews.llvm.org/D91970
Diffstat (limited to 'lld/MachO')
-rw-r--r-- | lld/MachO/DriverUtils.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lld/MachO/DriverUtils.cpp b/lld/MachO/DriverUtils.cpp index 3899348666b4..0322c20fcb69 100644 --- a/lld/MachO/DriverUtils.cpp +++ b/lld/MachO/DriverUtils.cpp @@ -75,8 +75,14 @@ opt::InputArgList MachOOptTable::parse(ArrayRef<const char *> argv) { handleColorDiagnostics(args); - for (opt::Arg *arg : args.filtered(OPT_UNKNOWN)) - error("unknown argument: " + arg->getSpelling()); + for (opt::Arg *arg : args.filtered(OPT_UNKNOWN)) { + std::string nearest; + if (findNearest(arg->getAsString(args), nearest) > 1) + error("unknown argument '" + arg->getAsString(args) + "'"); + else + error("unknown argument '" + arg->getAsString(args) + + "', did you mean '" + nearest + "'"); + } return args; } |