https://github.com/Abhay13332 updated 
https://github.com/llvm/llvm-project/pull/230846

>From 9fcdd8eca06264b57a8042926da5aa0e3a570568 Mon Sep 17 00:00:00 2001
From: abhay13332 <[email protected]>
Date: Tue, 13 Oct 2026 14:02:59 +0530
Subject: [PATCH 1/6] [clang-tidy] Fix false negatives in
 bugprone-redundant-branch-condition on cases like if (x && y) { if (y) ... }

---
 .../bugprone/RedundantBranchConditionCheck.cpp    |  7 +++----
 clang-tools-extra/docs/ReleaseNotes.md            | 12 +++++++++---
 .../bugprone/redundant-branch-condition.cpp       | 15 ++++++++++++++-
 3 files changed, 26 insertions(+), 8 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
index 8d608dd4b0e666..7934da1f2fbddd 100644
--- a/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
@@ -76,10 +76,9 @@ void 
RedundantBranchConditionCheck::registerMatchers(MatchFinder *Finder) {
       ifStmt(
           hasCondition(anyOf(
               declRefExpr(hasDeclaration(ImmutableVar)).bind(OuterIfVar1Str),
-              binaryOperator(
-                  hasOperatorName("&&"),
-                  hasEitherOperand(declRefExpr(hasDeclaration(ImmutableVar))
-                                       .bind(OuterIfVar2Str))))),
+              binaryOperator(hasOperatorName("&&"),
+                             forEach(declRefExpr(hasDeclaration(ImmutableVar))
+                                         .bind(OuterIfVar2Str))))),
           hasThen(hasDescendant(
               ifStmt(hasCondition(anyOf(
                          declRefExpr(hasDeclaration(
diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index 14480052535567..c151210f68a4a7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -203,9 +203,15 @@ infrastructure are described first, followed by 
tool-specific sections.
   the pointer points to an incomplete (forward-declared) type.
 
 - Improved {doc}`bugprone-redundant-branch-condition
-  <clang-tidy/checks/bugprone/redundant-branch-condition>` check by fixing
-  false positives when the condition variable is changed later in a loop that
-  encloses the inner `if`.
+  <clang-tidy/checks/bugprone/redundant-branch-condition>` check:
+  
+    - Fixed false positives when the condition variable is changed later in a 
loop that
+      encloses the inner `if`.
+
+    - Fixed false negatives when there are two varibles statement in both side
+      of `&&` in `if` like `a && b` .it showing correct warning for first 
variable
+      and failed for second variable in if condition.eg.  `(x && y) { if (y) 
... }`
+      in this example warning is not shown properly. 
 
 - Fixed a crash in {doc}`bugprone-std-namespace-modification
   <clang-tidy/checks/bugprone/std-namespace-modification>` when checking
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
index ad2238ff9984f3..57ab6456a99878 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
@@ -12,7 +12,7 @@ bool tryToExtinguishByVal(bool);
 void tryPutFireOut();
 bool callTheFD();
 void scream();
-
+bool isFireFighterComing();
 bool someOtherCondition();
 
 //===--- Basic Positives 
--------------------------------------------------===//
@@ -278,6 +278,19 @@ void positive_direct_outer_and_rhs() {
     // CHECK-FIXES: {{^\ *$}}
   }
 }
+void positive_direct_outer_and_rhs_bool() {
+  bool onFire = isBurning();
+  bool isComing = isFireFighterComing();
+  if (isComing && onFire) {
+    if (onFire) {
+      // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'onFire' 
[bugprone-redundant-branch-condition]
+      // CHECK-FIXES: {{^\ *$}}
+      scream();
+    }
+    // CHECK-FIXES: {{^\ *$}}
+  }
+}
+
 
 void positive_indirect_outer_and_rhs() {
   bool onFire = isBurning();

>From f6c51c781987301a9c17e0efc700baf9e323518c Mon Sep 17 00:00:00 2001
From: abhay13332 <[email protected]>
Date: Sat, 17 Oct 2026 11:06:52 +0530
Subject: [PATCH 2/6] [clang-tidy] fix documentation clarity in realese notes
 for bugprone-redundant-branch-condition

---
 clang-tools-extra/docs/ReleaseNotes.md | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index c151210f68a4a7..f5d9a38b68cbb6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -208,10 +208,12 @@ infrastructure are described first, followed by 
tool-specific sections.
     - Fixed false positives when the condition variable is changed later in a 
loop that
       encloses the inner `if`.
 
-    - Fixed false negatives when there are two varibles statement in both side
-      of `&&` in `if` like `a && b` .it showing correct warning for first 
variable
-      and failed for second variable in if condition.eg.  `(x && y) { if (y) 
... }`
-      in this example warning is not shown properly. 
+    - Fixed false negatives when two variables are present on both sides
+      of logical AND(`&&`) in `if` like `a && b`. Previously, it was only 
evaluated for 
+      first variable `a` and completely ignored the second variable `b` for 
redundant
+      branch condition.For example, In `(x && y) { if (y){} if(x){} }` a 
warning was
+      only generated for nested `if` with x(`if(x){}`) and never generated for 
nested `if`
+      with y(`if (y){}`).
 
 - Fixed a crash in {doc}`bugprone-std-namespace-modification
   <clang-tidy/checks/bugprone/std-namespace-modification>` when checking

>From 0b6e1c7579a8625651db14c79808e2c563ac3cc0 Mon Sep 17 00:00:00 2001
From: Abhay Singh <[email protected]>
Date: Wed, 21 Oct 2026 16:24:08 +0530
Subject: [PATCH 3/6] Update clang-tools-extra/docs/ReleaseNotes.md

Co-authored-by: EugeneZelenko <[email protected]>
---
 clang-tools-extra/docs/ReleaseNotes.md | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index f5d9a38b68cbb6..64113ba18df59d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -209,11 +209,7 @@ infrastructure are described first, followed by 
tool-specific sections.
       encloses the inner `if`.
 
     - Fixed false negatives when two variables are present on both sides
-      of logical AND(`&&`) in `if` like `a && b`. Previously, it was only 
evaluated for 
-      first variable `a` and completely ignored the second variable `b` for 
redundant
-      branch condition.For example, In `(x && y) { if (y){} if(x){} }` a 
warning was
-      only generated for nested `if` with x(`if(x){}`) and never generated for 
nested `if`
-      with y(`if (y){}`).
+      of logical AND (`&&`) in `if` like `a && b`.
 
 - Fixed a crash in {doc}`bugprone-std-namespace-modification
   <clang-tidy/checks/bugprone/std-namespace-modification>` when checking

>From 178c78d5eaf55c45158070245d355d82511c027a Mon Sep 17 00:00:00 2001
From: Abhay Singh <[email protected]>
Date: Wed, 21 Oct 2026 20:44:18 +0530
Subject: [PATCH 4/6] Update
 
clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp

Co-authored-by: EugeneZelenko <[email protected]>
---
 .../clang-tidy/checkers/bugprone/redundant-branch-condition.cpp  | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
index 57ab6456a99878..2f71fc8e2920e7 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/redundant-branch-condition.cpp
@@ -291,7 +291,6 @@ void positive_direct_outer_and_rhs_bool() {
   }
 }
 
-
 void positive_indirect_outer_and_rhs() {
   bool onFire = isBurning();
   if (fireFighters < 10 && onFire) {

>From 618bacff70b7efda8ce1b04ecd9e397faa93c4fc Mon Sep 17 00:00:00 2001
From: Abhay Singh <[email protected]>
Date: Sun, 25 Oct 2026 00:26:54 +0530
Subject: [PATCH 5/6] Update clang-tools-extra/docs/ReleaseNotes.md

Co-authored-by: Zeyi Xu <[email protected]>
---
 clang-tools-extra/docs/ReleaseNotes.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index 64113ba18df59d..cd608f0d8b8f26 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -209,7 +209,6 @@ infrastructure are described first, followed by 
tool-specific sections.
       encloses the inner `if`.
 
     - Fixed false negatives when two variables are present on both sides
-      of logical AND (`&&`) in `if` like `a && b`.
 
 - Fixed a crash in {doc}`bugprone-std-namespace-modification
   <clang-tidy/checks/bugprone/std-namespace-modification>` when checking

>From c81f5871bee42f5a40f5fa646f643f9d5c04c5a4 Mon Sep 17 00:00:00 2001
From: Abhay Singh <[email protected]>
Date: Sun, 25 Oct 2026 00:27:21 +0530
Subject: [PATCH 6/6] Update clang-tools-extra/docs/ReleaseNotes.md

Co-authored-by: Zeyi Xu <[email protected]>
---
 clang-tools-extra/docs/ReleaseNotes.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/docs/ReleaseNotes.md 
b/clang-tools-extra/docs/ReleaseNotes.md
index cd608f0d8b8f26..0150c068efd974 100644
--- a/clang-tools-extra/docs/ReleaseNotes.md
+++ b/clang-tools-extra/docs/ReleaseNotes.md
@@ -208,7 +208,8 @@ infrastructure are described first, followed by 
tool-specific sections.
     - Fixed false positives when the condition variable is changed later in a 
loop that
       encloses the inner `if`.
 
-    - Fixed false negatives when two variables are present on both sides
+    - Fixed false negatives when a nested `if` checks the second operand
+      of an outer `&&` condition, as in `if (x && y) { if (y) ... }`.
 
 - Fixed a crash in {doc}`bugprone-std-namespace-modification
   <clang-tidy/checks/bugprone/std-namespace-modification>` when checking

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

Reply via email to