[clang-tools-extra] [clang-tidy] fix false positive of parentheses removal for overloaded operator (PR #192254)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 18 06:19: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())))))
----------------
vbvictor wrote:

I didn't think about this properly, but at first glance this seeme too specific for this case. `hasDescendant` matches any child node so we may bring false negatives. Do we need to use specifically descendant and not plain `has()`?

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


More information about the cfe-commits mailing list