[PATCH] D41873: [Option] For typo '-foo', suggest '--foo'

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 11:55:19 PDT 2018


thakis added inline comments.


================
Comment at: lib/Option/OptTable.cpp:281
+    StringRef Prefix = CandidateInfo.Prefixes[0];
+    for (int P = 1; CandidateInfo.Prefixes[P]; P++) {
       if (Option.startswith(CandidateInfo.Prefixes[P]))
----------------
This relies on '--' being later in Prefixes than '-'. If '--' is Prefixes[0] is -- and then Prefixes[1] is -, then Option.startswith (Prefixes[1]) is true and we switch from -- to - for flags that start with --.

And -- being later in Prefixes isn't guaranteed.


https://reviews.llvm.org/D41873





More information about the llvm-commits mailing list