Switch constant evaluation of float casts over to cast kinds.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128251 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index c44428b..9ce98b7 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -2166,7 +2166,15 @@
bool FloatExprEvaluator::VisitCastExpr(CastExpr *E) {
Expr* SubExpr = E->getSubExpr();
- if (SubExpr->getType()->isIntegralOrEnumerationType()) {
+ switch (E->getCastKind()) {
+ default:
+ return false;
+
+ case CK_LValueToRValue:
+ case CK_NoOp:
+ return Visit(SubExpr);
+
+ case CK_IntegralToFloating: {
APSInt IntResult;
if (!EvaluateInteger(SubExpr, IntResult, Info))
return false;
@@ -2174,7 +2182,8 @@
IntResult, Info.Ctx);
return true;
}
- if (SubExpr->getType()->isRealFloatingType()) {
+
+ case CK_FloatingCast: {
if (!Visit(SubExpr))
return false;
Result = HandleFloatToFloatCast(E->getType(), SubExpr->getType(),
@@ -2182,13 +2191,14 @@
return true;
}
- if (E->getCastKind() == CK_FloatingComplexToReal) {
+ case CK_FloatingComplexToReal: {
ComplexValue V;
if (!EvaluateComplex(SubExpr, V, Info))
return false;
Result = V.getComplexFloatReal();
return true;
}
+ }
return false;
}