[clang] Resolve redundant predicates (PR #79701)

via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 27 10:07:33 PST 2024


https://github.com/Rageking8 created https://github.com/llvm/llvm-project/pull/79701

Fixes #79686

>From 6d0591f238444674f327ca502a93ad72bdd46110 Mon Sep 17 00:00:00 2001
From: Rageking8 <106309953+Rageking8 at users.noreply.github.com>
Date: Sun, 28 Jan 2024 02:06:39 +0800
Subject: [PATCH] Resolve redundant predicates

---
 clang/lib/Sema/SemaChecking.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 502b24bcdf8b42b..532c1073b48b747 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -17185,7 +17185,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
     //  evaluates to true.
     bool EvalResult = false;
     bool EvalOK = Eval.evaluate(BO->getLHS(), EvalResult);
-    bool ShouldVisitRHS = !EvalOK || (EvalOK && !EvalResult);
+    bool ShouldVisitRHS = !EvalOK || !EvalResult;
     if (ShouldVisitRHS) {
       Region = RHSRegion;
       Visit(BO->getRHS());
@@ -17217,7 +17217,7 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
     //  [...] the second operand is not evaluated if the first operand is false.
     bool EvalResult = false;
     bool EvalOK = Eval.evaluate(BO->getLHS(), EvalResult);
-    bool ShouldVisitRHS = !EvalOK || (EvalOK && EvalResult);
+    bool ShouldVisitRHS = !EvalOK || EvalResult;
     if (ShouldVisitRHS) {
       Region = RHSRegion;
       Visit(BO->getRHS());
@@ -17268,8 +17268,8 @@ class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> {
     // evaluated. [...]
     bool EvalResult = false;
     bool EvalOK = Eval.evaluate(CO->getCond(), EvalResult);
-    bool ShouldVisitTrueExpr = !EvalOK || (EvalOK && EvalResult);
-    bool ShouldVisitFalseExpr = !EvalOK || (EvalOK && !EvalResult);
+    bool ShouldVisitTrueExpr = !EvalOK || EvalResult;
+    bool ShouldVisitFalseExpr = !EvalOK || !EvalResult;
     if (ShouldVisitTrueExpr) {
       Region = TrueRegion;
       Visit(CO->getTrueExpr());



More information about the cfe-commits mailing list