In the expression evaluator, visit the index of an ArraySubscriptExpr even if we can't evaluate the base, if the evaluation mode tells us to continue evaluation.

llvm-svn: 301522
This commit is contained in:
Nick Lewycky 2017-04-27 07:27:36 +00:00
parent 7b0ec39494
commit ad8886896e
2 changed files with 12 additions and 3 deletions

View File

@ -5246,14 +5246,19 @@ bool LValueExprEvaluator::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
if (E->getBase()->getType()->isVectorType())
return Error(E);
if (!evaluatePointer(E->getBase(), Result))
return false;
bool Success = true;
if (!evaluatePointer(E->getBase(), Result)) {
if (!Info.noteFailure())
return false;
Success = false;
}
APSInt Index;
if (!EvaluateInteger(E->getIdx(), Index, Info))
return false;
return HandleLValueArrayAdjustment(Info, E, Result, E->getType(), Index);
return Success &&
HandleLValueArrayAdjustment(Info, E, Result, E->getType(), Index);
}
bool LValueExprEvaluator::VisitUnaryDeref(const UnaryOperator *E) {

View File

@ -147,6 +147,10 @@ uint64_t check_integer_overflows(int i) {
uint64_t a[10];
a[4608 * 1024 * 1024] = 1i;
// expected-warning@+2 {{overflow in expression; result is 536870912 with type 'int'}}
uint64_t *b;
uint64_t b2 = b[4608 * 1024 * 1024] + 1;
// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
(void)((i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024)) + 1);