[PATCH] D46776: [Option] Fix PR37006 prefix choice in findNearest

Brian Gesiak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 11 14:37:35 PDT 2018


modocache created this revision.
modocache added a reviewer: thakis.

In https://bugs.llvm.org/show_bug.cgi?id=37006 Nico Weber points out a
flaw in `OptTable::findNearest`: if an option "foo"'s prefixes are "--"
and "-", then the nearest option for "--fob" will be "-foo". This is
incorrect, however, since the function is expected to return "--foo".

The bug is due to a naive loop that attempts to predetermines which
prefix is best. Instead, compute the edit distance for each prefix/name
pair.

Test Plan: `check-llvm`


Repository:
  rL LLVM

https://reviews.llvm.org/D46776

Files:
  lib/Option/OptTable.cpp
  unittests/Option/OptionParsingTest.cpp
  unittests/Option/Opts.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46776.146415.patch
Type: text/x-patch
Size: 4971 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180511/177c9149/attachment.bin>


More information about the llvm-commits mailing list