[clang-tools-extra] [clang-tidy] Fix false positives with deducing this in `readability-convert-member-functions-to-static` check (PR #141391)

via cfe-commits cfe-commits at lists.llvm.org
Sat May 24 23:42:54 PDT 2025


================
@@ -62,6 +62,16 @@ AST_MATCHER(CXXMethodDecl, usesThis) {
       return false; // Stop traversal.
     }
 
+    bool VisitDeclRefExpr(const DeclRefExpr *E) {
+      if (const auto *PVD = dyn_cast_if_present<ParmVarDecl>(E->getDecl());
+          PVD && PVD->isExplicitObjectParameter()) {
+        Used = true;
+        return false; // Stop traversal.
+      }
+
+      return true;
+    }
----------------
flovent wrote:

You're right, traversing is not necessary, i ignore the fact that member functions can't be static as long as they have explicit `this` as parameter.




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


More information about the cfe-commits mailing list