[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
Mon Apr 13 23:22:40 PDT 2026
================
@@ -235,3 +235,38 @@ struct NoFixitInMacro {
return;
}
};
+
+
+struct OverloadedMethods {
+ void f() {
+ this->i++;
+ }
+ void f() const {
+ ;
----------------
gxyd wrote:
I think we do actually need the `;`, because in it's absence the function will be declared as having a trivial body. That would mean the matcher (under consideration): https://github.com/llvm/llvm-project/blob/d9c02ffa4d519245903ba8d168b3bafeb1a396af/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp#L83-L99
would never match. Hence, we'll never be actually testing the `hasNonConstOverload` (the utility I just added).
Let me know if you still think otherwise.
https://github.com/llvm/llvm-project/pull/191712
More information about the cfe-commits
mailing list