[llvm] [CommandLine] Better report unknown subcommands (PR #74811)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 8 00:27:31 PST 2023


================
@@ -561,7 +565,19 @@ SubCommand *CommandLineParser::LookupSubCommand(StringRef Name) {
 
     if (StringRef(S->getName()) == StringRef(Name))
       return S;
+
+    unsigned Distance =
+        Name.edit_distance(S->getName(), /*AllowReplacements=*/true,
----------------
MaskRay wrote:

In clang and lld, we do something like `if (OptTbl.findNearest(ArgString, Nearest, VisibilityMask) > 1) ` to reject a candidate with a too large edit distance

https://github.com/llvm/llvm-project/pull/74811


More information about the llvm-commits mailing list