summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2018-10-23 17:55:35 +0000
committerLeonard Chan <leonardchan@google.com>2018-10-23 17:55:35 +0000
commitb4ba467da89353fda84a08175971859b1e52fde4 (patch)
tree5717ccd5f1108933d71925a52a4c7345119b6d10 /clang/lib/AST/ExprConstant.cpp
parent29d8639732bc367aab862529779c70e43e463d0c (diff)
downloadbcm5719-llvm-b4ba467da89353fda84a08175971859b1e52fde4.tar.gz
bcm5719-llvm-b4ba467da89353fda84a08175971859b1e52fde4.zip
[Fixed Point Arithmetic] Fixed Point to Boolean Cast
This patch is a part of https://reviews.llvm.org/D48456 in an attempt to split the casting logic up into smaller patches. This contains the code for casting from fixed point types to boolean types. Differential Revision: https://reviews.llvm.org/D53308 llvm-svn: 345063
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index a7da24db6a2..c64e335255e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9590,6 +9590,14 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
return Success(IntResult, E);
}
+ case CK_FixedPointToBoolean: {
+ // Unsigned padding does not affect this.
+ APValue Val;
+ if (!Evaluate(Val, Info, SubExpr))
+ return false;
+ return Success(Val.getInt().getBoolValue(), E);
+ }
+
case CK_IntegralCast: {
if (!Visit(SubExpr))
return false;
@@ -10090,6 +10098,7 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
case CK_AddressSpaceConversion:
case CK_IntToOCLSampler:
case CK_FixedPointCast:
+ case CK_FixedPointToBoolean:
llvm_unreachable("invalid cast kind for complex value");
case CK_LValueToRValue:
OpenPOWER on IntegriCloud