[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
Sun Apr 12 06:55:41 PDT 2026


================
@@ -235,3 +235,38 @@ struct NoFixitInMacro {
     return;
   }
 };
+
+
+struct OverloadedMethods {
+  void f() {
+    this->i++;
+  }
+  void f() const {
+    ;
+  };
+
+  void g(int) {
+    this->i++;
+  }
+  void g(int) const {
+    ;
+  };
+
+  void h(int) {
+    this->i++;
+  };
+  void h(float) const {
+    // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'h' can be made static
+    // CHECK-FIXES: static void h(float) {
+    ;
+  };
+
+  void j() {
+    this->i++;
+  }
+  int j() const {
+    ;
+  }
----------------
gxyd wrote:

This example currently on `main` (does Godbolt uses `main` of LLVM?) raises an incorrect warning: https://godbolt.org/z/eM6acb3zh , which I confirmed isn't a valid `-fix`.

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


More information about the cfe-commits mailing list