https://github.com/mirimmad updated 
https://github.com/llvm/llvm-project/pull/187054

>From 6c083f9ec004bc054829fd1cc8df9b9de4a408f4 Mon Sep 17 00:00:00 2001
From: Immad Mir <[email protected]>
Date: Tue, 17 Mar 2026 21:57:00 +0530
Subject: [PATCH 1/3] match against 'memberExpr'

---
 .../clang-tidy/readability/RedundantParenthesesCheck.cpp    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
index bb993a60c9d4e..38cca7790670a 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
@@ -54,7 +54,11 @@ void RedundantParenthesesCheck::registerMatchers(MatchFinder 
*Finder) {
       parenExpr(subExpr(anyOf(
                     parenExpr(), ConstantExpr,
                     declRefExpr(to(namedDecl(unless(
-                        
matchers::matchesAnyListedRegexName(AllowedDecls))))))),
+                        matchers::matchesAnyListedRegexName(AllowedDecls))))),
+                        memberExpr()
+                      
+                      )),
+                    
                 unless(anyOf(isInMacro(),
                              // sizeof(...) is common used.
                              hasParent(unaryExprOrTypeTraitExpr()))))

>From 88eaf77cd3d52a4fb50a908e6351dd5043ab3620 Mon Sep 17 00:00:00 2001
From: Immad Mir <[email protected]>
Date: Wed, 18 Mar 2026 12:08:40 +0530
Subject: [PATCH 2/3] add tests

---
 .../readability/RedundantParenthesesCheck.cpp |  5 +---
 .../readability/redundant-parentheses.cpp     | 24 +++++++++++++++++++
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
index 38cca7790670a..fa69c4b72eeb6 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
@@ -55,10 +55,7 @@ void RedundantParenthesesCheck::registerMatchers(MatchFinder 
*Finder) {
                     parenExpr(), ConstantExpr,
                     declRefExpr(to(namedDecl(unless(
                         matchers::matchesAnyListedRegexName(AllowedDecls))))),
-                        memberExpr()
-                      
-                      )),
-                    
+                    memberExpr())),
                 unless(anyOf(isInMacro(),
                              // sizeof(...) is common used.
                              hasParent(unaryExprOrTypeTraitExpr()))))
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
index c77608c66469c..7e3d4b4d61f29 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
@@ -71,3 +71,27 @@ void ignoreStdMaxMin() {
   (std::max)(1,2);
   (std::min)(1,2);
 }
+
+struct Foo
+{
+  bool x;
+  void foo()
+  {
+   if ((x)) {
+     // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+     // CHECK-FIXES:    if (x) {
+   }
+   if((this->x)) {
+     // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+     // CHECK-FIXES:    if(this->x) {
+   }
+  }
+};
+
+void memberExpr() {
+  Foo foo{};
+  if ((foo.x)) {
+   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
+   // CHECK-FIXES:    if (foo.x) {
+  }
+}
\ No newline at end of file

>From 154bdc088992c033ab4a5e0326780091254a703d Mon Sep 17 00:00:00 2001
From: Immad Mir <[email protected]>
Date: Wed, 18 Mar 2026 12:30:50 +0530
Subject: [PATCH 3/3] add a new line at EOF

---
 .../clang-tidy/checkers/readability/redundant-parentheses.cpp   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
index 7e3d4b4d61f29..8f977d9ab7708 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/redundant-parentheses.cpp
@@ -94,4 +94,4 @@ void memberExpr() {
    // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant parentheses around 
expression [readability-redundant-parentheses]
    // CHECK-FIXES:    if (foo.x) {
   }
-}
\ No newline at end of file
+}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to