https://github.com/gxyd updated https://github.com/llvm/llvm-project/pull/191432
>From 504f90764c855abbc01a07bdbc98406893d57c5b Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra <[email protected]> Date: Fri, 10 Apr 2026 19:55:21 +0530 Subject: [PATCH 1/3] [clang-tidy] Unresolve member function call can't be static readability-convert-member-functions-to-static incorrectly suggests making overloaded member function, with lambda function call, as static (false-positive) Mark usage of "this" as true, when a call to "UnresolveMemberExpr" is obvserved Fixes #171626 --- .../readability/ConvertMemberFunctionsToStaticCheck.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp index 4bca9686e94e1..366f078d8f2ec 100644 --- a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp @@ -64,6 +64,11 @@ AST_MATCHER(CXXMethodDecl, usesThis) { return false; // Stop traversal. } + bool VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *E) { + Used = true; + return false; + } + // If we enter a class declaration, don't traverse into it as any usages of // `this` will correspond to the nested class. bool TraverseCXXRecordDecl(CXXRecordDecl *RD) { return true; } >From 58b8421c62ad76a7d46cac162d875f57c32a36c0 Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra <[email protected]> Date: Fri, 10 Apr 2026 20:07:06 +0530 Subject: [PATCH 2/3] add tests for overloaded unresolve with lambda call --- ...mber-functions-to-static-deducing-this.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static-deducing-this.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static-deducing-this.cpp index a6ca86dd7cefa..790c8f0f927cc 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static-deducing-this.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/convert-member-functions-to-static-deducing-this.cpp @@ -20,3 +20,27 @@ struct Hello { void UnnamedExplicitObjectParam(this Hello &) {} }; + + +class OverloadedUnresolvedWithAutoLambda { +public: + void CallsFunctionVar(); + void CallsOverloadedMethodWithArg(int a); + void OverloadedMethodWithoutArg(); + void OverloadedMethodWithArg(int a) { }; +}; + +void OverloadedUnresolvedWithAutoLambda::CallsFunctionVar() { + // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: method 'CallsFunctionVar' can be made static [readability-convert-member-functions-to-static] + auto fun = [&](auto a) { + var(a); + }; +} + +void OverloadedUnresolvedWithAutoLambda::CallsOverloadedMethodWithArg(int a) { + auto fun = [&](auto b) { + OverloadedMethodWithArg(b); + }; +} + +void Var(int a) { } >From 3c3ee23e3a68d9db7600ece851a634fdd8f94b6e Mon Sep 17 00:00:00 2001 From: Gaurav Dhingra <[email protected]> Date: Sun, 12 Apr 2026 21:16:37 +0530 Subject: [PATCH 3/3] add ReleaseNotes entry --- clang-tools-extra/docs/ReleaseNotes.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 02315415b975f..3f93f478e992d 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -412,6 +412,11 @@ Changes in existing checks - Reduce verbosity by removing the note indicating source location of the ``empty`` function. +- Improved :doc:`readability-convert-member-functions-to-static + <clang-tidy/checks/readability/convert-member-functions-to-static>` check to + correctly detect ``this`` usage within a member function with a call to an + overloaded method inside a generic lambda. + - Improved :doc:`readability-else-after-return <clang-tidy/checks/readability/else-after-return>` check: _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
