[clang-tools-extra] [clang-tidy][NFC] Refactor `bugprone-argument-comment` [1/3] (PR #172521)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 16 09:24:59 PST 2025


================
@@ -164,28 +164,27 @@ static bool isLikelyTypo(const NamedDeclRange &Candidates, StringRef ArgName,
   if (ThisED >= UpperBound)
     return false;
 
-  for (const auto &Candidate : Candidates) {
-    const IdentifierInfo *II = Candidate->getIdentifier();
-    if (II->getName() == TargetName)
-      continue;
-
-    if (!II)
-      continue;
-
-    const unsigned Threshold = 2;
-    // Other candidates must be an edit distance at least Threshold more away
-    // from this candidate. This gives us greater confidence that this is a
-    // typo of this candidate and not one with a similar name.
-    const llvm::SmallString<64> CandidateLower =
-        getLowercasedString(II->getName());
-    const unsigned OtherED = ArgNameLowerRef.edit_distance(
-        StringRef(CandidateLower),
-        /*AllowReplacements=*/true, ThisED + Threshold);
-    if (OtherED < ThisED + Threshold)
-      return false;
-  }
-
-  return true;
+  return std::all_of(Candidates.begin(), Candidates.end(),
----------------
vbvictor wrote:

We should use `llvm::all_of(Candidates, [&]() {...})`.
We have check https://clang.llvm.org/extra/clang-tidy/checks/llvm/use-ranges.html for it, but it is only enabled in clang-tidy-22 (CI has 21)

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


More information about the cfe-commits mailing list