[clang] Resolve redundant predicates (PR #79701)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 27 10:08:03 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (Rageking8)
<details>
<summary>Changes</summary>
Fixes #<!-- -->79686
---
Full diff: https://github.com/llvm/llvm-project/pull/79701.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaChecking.cpp (+4-4)
``````````diff
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());
``````````
</details>
https://github.com/llvm/llvm-project/pull/79701
More information about the cfe-commits
mailing list