[clang-tools-extra] [clang-tidy] fix false positive of parentheses removal for overloaded operator (PR #192254)
Gaurav Dhingra via cfe-commits
cfe-commits at lists.llvm.org
Sat May 16 06:52:09 PDT 2026
================
@@ -58,7 +58,9 @@ void RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
memberExpr(), callExpr())),
unless(anyOf(isInMacro(),
// sizeof(...) is common used.
- hasParent(unaryExprOrTypeTraitExpr()))))
+ hasParent(unaryExprOrTypeTraitExpr()),
+ allOf(hasDescendant(cxxOperatorCallExpr()),
+ hasParent(binaryOperator())))))
----------------
gxyd wrote:
Yes, you were right about this. I've used `has` now instead of `hasDescendant` and added a test case which would've created a false-negative with `hasDescendant` use instead of `has`.
I think this PR is now ready for a review.
https://github.com/llvm/llvm-project/pull/192254
More information about the cfe-commits
mailing list