[clang-tools-extra] [clang-tidy] Fix false positive in readability-redundant-parentheses … (PR #192827)
Daniil Dudkin via cfe-commits
cfe-commits at lists.llvm.org
Sun May 3 12:23:07 PDT 2026
================
@@ -32,6 +32,26 @@ AST_MATCHER(ParenExpr, isInMacro) {
E->getBeginLoc().isMacroID() || E->getEndLoc().isMacroID();
}
+// Returns true if this ParenExpr is the base object of a member access
+// (.field or ->field), possibly through implicit casts or temporary
+// materialization that Clang inserts (e.g. qualification casts for const
+// methods, MaterializeTemporaryExpr for prvalue bases).
+AST_MATCHER(ParenExpr, isBaseOfMemberAccess) {
----------------
unterumarmung wrote:
This suppresses too much. It treats any parenthesized expression used as a member-access base as non-redundant, so cases like `(foo).x`, `(foo.bar()).z`, or `(makeFoo()).x` would stop warning even though removing the parentheses is valid. The exemption should be limited to cases where the parentheses are syntactically required, such as overloaded operator calls used as the base: `(s << "x").str()`, `(*it).x`, `(*it)->x`.
https://github.com/llvm/llvm-project/pull/192827
More information about the cfe-commits
mailing list