Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][NFC] resolve redundant predicates #79701

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

Rageking8
Copy link
Contributor

Fixes #79686

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 27, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 27, 2024

@llvm/pr-subscribers-clang

Author: None (Rageking8)

Changes

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 --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());

@inclyc inclyc changed the title Resolve redundant predicates [clang] resolve redundant predicates Jan 28, 2024
Copy link
Member

@inclyc inclyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an NFC patch

@inclyc inclyc changed the title [clang] resolve redundant predicates [clang][NFC] resolve redundant predicates Jan 28, 2024
@cor3ntin
Copy link
Contributor

cor3ntin commented Feb 7, 2024

@Rageking8 Thanks the patch. Do you need us to merge that for you?

@Rageking8
Copy link
Contributor Author

@cor3ntin Yes, please.

@cor3ntin cor3ntin merged commit 351f94d into llvm:main Feb 8, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clang/lib/Sema/SemaChecking.cpp: 4 * Redundant conditions ?
4 participants