aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-22 02:13:06 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-22 02:13:06 +0000
commit9293fff58aa0198fa7a6bb504169bcac01dbbff7 (patch)
treeca02907b5143921a8b0b9ee8b11dc6694b247ce3 /lib/AST/ExprConstant.cpp
parentf5aa3f5e58356d0bea823fe75dd7bf6aea6f47f4 (diff)
Simplify DataRecursiveIntBinOpEvaluator::VisitBinOp() a bit and make sure we don't
evaluate RHS if LHS could not be evaluated and keepEvaluatingAfterFailure() is false. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r--lib/AST/ExprConstant.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 583bbfc988..0d8490e137 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -4537,8 +4537,8 @@ private:
return Info.CCEDiag(E, D);
}
- bool VisitBinOpLHSOnly(const EvalResult &LHSResult, const BinaryOperator *E,
- bool &IgnoreRHS, APValue &Result,
+ // \brief Returns true if visiting the RHS is necessary, false otherwise.
+ bool VisitBinOpLHSOnly(EvalResult &LHSResult, const BinaryOperator *E,
bool &SuppressRHSDiags);
bool VisitBinOp(const EvalResult &LHSResult, const EvalResult &RHSResult,
@@ -4563,8 +4563,7 @@ private:
}
bool DataRecursiveIntBinOpEvaluator::
- VisitBinOpLHSOnly(const EvalResult &LHSResult, const BinaryOperator *E,
- bool &IgnoreRHS, APValue &Result,
+ VisitBinOpLHSOnly(EvalResult &LHSResult, const BinaryOperator *E,
bool &SuppressRHSDiags) {
if (E->getOpcode() == BO_Comma) {
// Ignore LHS but note if we could not evaluate it.
@@ -4579,8 +4578,8 @@ bool DataRecursiveIntBinOpEvaluator::
// We were able to evaluate the LHS, see if we can get away with not
// evaluating the RHS: 0 && X -> 0, 1 || X -> 1
if (lhsResult == (E->getOpcode() == BO_LOr)) {
- IgnoreRHS = true;
- return Success(lhsResult, E, Result);
+ Success(lhsResult, E, LHSResult.Val);
+ return false; // Ignore RHS
}
} else {
// Since we weren't able to evaluate the left hand side, it
@@ -4600,8 +4599,8 @@ bool DataRecursiveIntBinOpEvaluator::
E->getRHS()->getType()->isIntegralOrEnumerationType());
if (LHSResult.Failed && !Info.keepEvaluatingAfterFailure())
- return false;
-
+ return false; // Ignore RHS;
+
return true;
}
@@ -4803,17 +4802,14 @@ void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
case Job::BinOpKind: {
const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
- job.LHSResult.swap(Result);
- bool IgnoreRHS = false;
bool SuppressRHSDiags = false;
- Result.Failed = !VisitBinOpLHSOnly(job.LHSResult, Bop, IgnoreRHS,
- Result.Val, SuppressRHSDiags);
- if (IgnoreRHS) {
+ if (!VisitBinOpLHSOnly(Result, Bop, SuppressRHSDiags)) {
Queue.pop_back();
return;
}
if (SuppressRHSDiags)
job.startSpeculativeEval(Info);
+ job.LHSResult.swap(Result);
job.Kind = Job::BinOpVisitedLHSKind;
enqueue(Bop->getRHS());
return;