summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-12-04 03:00:44 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-12-04 03:00:44 +0000
commit5c40f09b3daae92b32daccadef5f32227751d8d0 (patch)
tree45775b43145b7ade976f3924706740d0a6ff4339 /clang/lib
parentafdf6cbf3ce6c9479e6d04a97bbd95833f5949fb (diff)
downloadbcm5719-llvm-5c40f09b3daae92b32daccadef5f32227751d8d0.tar.gz
bcm5719-llvm-5c40f09b3daae92b32daccadef5f32227751d8d0.zip
Don't assert if evaluation of an expression that we're syntactically required
to treat as an ICE results in undefined behavior. Instead, return the "natural" result of the operation (signed wraparound / inf / nan). llvm-svn: 254699
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ExprConstant.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index d80f466d99f..ffaf742030f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9408,7 +9408,11 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Value, const ASTContext &Ctx,
if (!isIntegerConstantExpr(Ctx, Loc))
return false;
- if (!EvaluateAsInt(Value, Ctx))
+ // The only possible side-effects here are due to UB discovered in the
+ // evaluation (for instance, INT_MAX + 1). In such a case, we are still
+ // required to treat the expression as an ICE, so we produce the folded
+ // value.
+ if (!EvaluateAsInt(Value, Ctx, SE_AllowSideEffects))
llvm_unreachable("ICE cannot be evaluated!");
return true;
}
OpenPOWER on IntegriCloud