File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ void ConvertMemberFunctionsToStatic::registerMatchers(MatchFinder *Finder) {
8181 unless (anyOf (
8282 isExpansionInSystemHeader (), isVirtual (), isStatic (),
8383 hasTrivialBody (), isOverloadedOperator (), cxxConstructorDecl (),
84- cxxDestructorDecl (), cxxConversionDecl (), isTemplate (),
84+ cxxDestructorDecl (), cxxConversionDecl (),
85+ isExplicitObjectMemberFunction (), isTemplate (),
8586 isDependentContext (),
8687 ofClass (anyOf (
8788 isLambda (),
Original file line number Diff line number Diff line change @@ -256,6 +256,10 @@ Changes in existing checks
256256 tolerating fix-it breaking compilation when functions is used as pointers
257257 to avoid matching usage of functions within the current compilation unit.
258258
259+ - Improved :doc: `readability-convert-member-functions-to-static
260+ <clang-tidy/checks/readability/convert-member-functions-to-static>` check by
261+ fixing false positives on member functions with an explicit object parameter.
262+
259263- Improved :doc: `readability-math-missing-parentheses
260264 <clang-tidy/checks/readability/math-missing-parentheses>` check by fixing
261265 false negatives where math expressions are the operand of assignment operators
Original file line number Diff line number Diff line change 1+ // RUN: %check_clang_tidy -std=c++23-or-later %s readability-convert-member-functions-to-static %t
2+
3+ namespace std {
4+ class string {};
5+ void println (const char *format, const std::string &str) {}
6+ }
7+
8+ struct Hello {
9+ std::string str_;
10+
11+ void ByValueSelf (this Hello self) { std::println (" Hello, {0}!" , self.str_ ); }
12+
13+ void ByLRefSelf (this Hello &self) { std::println (" Hello, {0}!" , self.str_ ); }
14+
15+ void ByRRefSelf (this Hello&& self) {}
16+
17+ template <typename Self> void ByForwardRefSelf (this Self&& self) {}
18+
19+ void MultiParam (this Hello &self, int a, double b) {}
20+
21+ void UnnamedExplicitObjectParam (this Hello &) {}
22+ };
You can’t perform that action at this time.
0 commit comments