[PATCH] D49736: [Basic] Emit warning flag suggestion only in case there's existing flag *similar* to the unknown one

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 16 10:42:58 PST 2018


arphaman added a comment.

Thanks for working on this, some minor comments:



================
Comment at: Basic/DiagnosticIDs.cpp:612
       // Two matches with the same distance, don't prefer one over the other.
-      Best = "";
+      NearestOption = "";
     } else if (Distance < BestDistance) {
----------------
Do we a test case that covers this line?


================
Comment at: Basic/Warnings.cpp:34
+namespace {
+  constexpr unsigned MaxLevenshteinDistForWarningSuggestion = 2;
+}
----------------
It would be helpful to have a brief comment explaining the rationale behind using the number `2`.


================
Comment at: Basic/Warnings.cpp:35
+  constexpr unsigned MaxLevenshteinDistForWarningSuggestion = 2;
+}
+
----------------
NIT: Missing `//end anonymous namespace`.


================
Comment at: Basic/Warnings.cpp:48
+    << (!Suggestion.empty()
+      && OptToSuggestionEditDist > 0
+      && OptToSuggestionEditDist <= MaxLevenshteinDistForWarningSuggestion)
----------------
Is it ever possible to have an edit distance of `0`? Wouldn't it mean the strings are the same?


Repository:
  rC Clang

https://reviews.llvm.org/D49736





More information about the cfe-commits mailing list