When evaluating integer expressions handle logical operators outside

VisitBinaryOperator() to reduce stack pressure for source with huge number
of logical operators.

Fixes rdar://10913206.

llvm-svn: 151460
This commit is contained in:
Argyrios Kyrtzidis 2012-02-25 21:38:16 +00:00
parent 908d2bebaf
commit 70f9eb571e
2 changed files with 2057 additions and 34 deletions

View File

@ -4095,6 +4095,9 @@ public:
}
bool VisitCallExpr(const CallExpr *E);
bool VisitBinLAnd(const BinaryOperator *E);
bool VisitBinLOr(const BinaryOperator *E);
bool VisitBinLogicalOp(const BinaryOperator *E);
bool VisitBinaryOperator(const BinaryOperator *E);
bool VisitOffsetOfExpr(const OffsetOfExpr *E);
bool VisitUnaryOperator(const UnaryOperator *E);
@ -4495,16 +4498,16 @@ static APSInt CheckedIntArithmetic(EvalInfo &Info, const Expr *E,
return Result;
}
bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (E->isAssignmentOp())
return Error(E);
if (E->getOpcode() == BO_Comma) {
VisitIgnoredValue(E->getLHS());
return Visit(E->getRHS());
// Handle logical operators outside VisitBinaryOperator() to reduce
// stack pressure for source with huge number of logical operators.
bool IntExprEvaluator::VisitBinLAnd(const BinaryOperator *E) {
return VisitBinLogicalOp(E);
}
bool IntExprEvaluator::VisitBinLOr(const BinaryOperator *E) {
return VisitBinLogicalOp(E);
}
if (E->isLogicalOp()) {
bool IntExprEvaluator::VisitBinLogicalOp(const BinaryOperator *E) {
// These need to be handled specially because the operands aren't
// necessarily integral nor evaluated.
bool lhsResult, rhsResult;
@ -4539,6 +4542,17 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
return false;
}
bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (E->isAssignmentOp())
return Error(E);
if (E->getOpcode() == BO_Comma) {
VisitIgnoredValue(E->getLHS());
return Visit(E->getRHS());
}
assert(!E->isLogicalOp() && "Logical ops not handled separately?");
QualType LHSTy = E->getLHS()->getType();
QualType RHSTy = E->getRHS()->getType();

File diff suppressed because it is too large Load Diff