[clang-tools-extra] [clang-tidy] Fix false positive in readability-convert-member-functions-to-static for const overloads (PR #191712)

Gaurav Dhingra via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 21 05:48:49 PDT 2026


================
@@ -135,6 +159,9 @@ void ConvertMemberFunctionsToStaticCheck::check(
     const MatchFinder::MatchResult &Result) {
   const auto *Definition = Result.Nodes.getNodeAs<CXXMethodDecl>("x");
 
+  if (Definition->isConst() && hasNonConstOverload(*Definition))
+    return;
----------------
gxyd wrote:

Makes sense, we actually had `hasNonConstOverload` as a Matcher earlier, but then I noticed the CI giving `llvm-prefer-static-over-anonymous-namespace` errors, so I converted `hasNonConstOverload` to a function.

I've reverted to `hasNonConstOverload` as a Matcher now, and fixed the warning by converting `hasSameParameterTypes` to a lambda within the Matcher (which should fix the warning).

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


More information about the cfe-commits mailing list