[clang-tools-extra] [clang-tidy] Fix readability-redundant-parentheses false positive on typeof (PR #223512)

Andre Sun via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 16 08:45:53 PDT 2026


================
@@ -79,7 +87,9 @@ void RedundantParenthesesCheck::registerMatchers(MatchFinder *Finder) {
                     arraySubscriptExpr())),
                 unless(anyOf(isInMacro(),
                              // sizeof(...) is common used.
-                             hasParent(unaryExprOrTypeTraitExpr()))))
+                             hasParent(unaryExprOrTypeTraitExpr()),
+                             // typeof(...) parentheses are required syntax.
+                             isTypeOfArgument())))
----------------
and2049 wrote:

Didn't see an existing matcher for `TypeOfExprTypeLoc` so I've replaced it with `hasParent(typeLoc(isTypeOfExprTypeLoc()))`  using a local matcher.

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


More information about the cfe-commits mailing list