[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


================
@@ -99,6 +99,26 @@ struct Foo
   }
 };
 
+// Parens used as the object of a member access are not redundant.
+struct Stream {
+  Stream &operator<<(const char *);
+  const char *str() const;
+};
+struct Val {
+  int x;
+};
+struct Iter {
+  Val operator*() const;
+};
+
+void memberAccessOnParen(Stream &s, Iter it) {
+  // (s << "x").str() -- parens required for method chaining; no warning.
+  (s << "x").str();
+
+  // (*it).x -- parens required before member access; no warning.
+  auto v = (*it).x;
----------------
unterumarmung wrote:

Please add negative coverage for `->` as well as `.`. The linked iterator issue includes `(*it)->getValue()`, and the matcher is intended to cover both member-access forms.


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


More information about the cfe-commits mailing list