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

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sat May 24 22:43:22 PDT 2025


================
@@ -0,0 +1,14 @@
+// RUN: %check_clang_tidy -std=c++23 %s readability-convert-member-functions-to-static %t
+
+namespace std{
+  class string {};
+  void println(const char *format, const std::string &str) {}
+}
+
+namespace PR141381 {
+struct Hello {
+  std::string str_;
+
+  void hello(this Hello &self) { std::println("Hello, {0}!", self.str_); }
----------------
vbvictor wrote:

Please add tests:
- with some are other parameters.
- unnamed object parameter (see p.5 of https://en.cppreference.com/w/cpp/language/function#Parameter_list)
- with `this Hello self`, `this Hello&& self`, `template<typename Self> void hello(this Self&& self);`

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


More information about the cfe-commits mailing list