[PATCH] D135389: [Clang] Emit a warning for ambiguous joined '-o' arguments

Joseph Huber via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 13:42:56 PDT 2022


jhuber6 marked 2 inline comments as done.
jhuber6 added inline comments.


================
Comment at: clang/lib/Driver/Driver.cpp:337
+    std::string Nearest;
+    if (getOpts().findNearest("-" + ArgString, Nearest, IncludedFlagsBitmask,
+                              ExcludedFlagsBitmask) == 1)
----------------
tra wrote:
> This looks for all 1-symbol mismatches. and may trigger on differences other than `--option` vs `-option`.  E.g. if user passes `-oip-link` (which looks like something we may see in real life), we'll try to find the nearest for `--oip-link` and will get a distance-1 match for the existing option `--hip-link`.
> 
> We may need to verify that the nearest match that we've found is indeed due to a missing leading `dash`.
> 
You're right, I changed it to use the raw string from the input. Since it's joined it will be the full string, so if we append a `-` to it and the edit length is zero then we know for a fact that it's due to a missing dash.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135389/new/

https://reviews.llvm.org/D135389



More information about the cfe-commits mailing list