[cfe-commits] r128251 - /cfe/trunk/lib/AST/ExprConstant.cpp

Eli Friedman eli.friedman at gmail.com
Thu Mar 24 17:54:52 PDT 2011


Author: efriedma
Date: Thu Mar 24 19:54:52 2011
New Revision: 128251

URL: http://llvm.org/viewvc/llvm-project?rev=128251&view=rev
Log:
Switch constant evaluation of float casts over to cast kinds.


Modified:
    cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=128251&r1=128250&r2=128251&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Mar 24 19:54:52 2011
@@ -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;
 }





More information about the cfe-commits mailing list