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

Eli Friedman eli.friedman at gmail.com
Sun Mar 22 21:56:02 PDT 2009


Author: efriedma
Date: Sun Mar 22 23:56:01 2009
New Revision: 67506

URL: http://llvm.org/viewvc/llvm-project?rev=67506&view=rev
Log:
Minor Evaluate cleanup; add some boilerplate implementations to 
Evaluate for __extension__ and __builtin_choose_expr.


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=67506&r1=67505&r2=67506&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Mar 22 23:56:01 2009
@@ -163,7 +163,11 @@
   APValue VisitObjCEncodeExpr(ObjCEncodeExpr *E) { return APValue(E, 0); }
   APValue VisitArraySubscriptExpr(ArraySubscriptExpr *E);
   APValue VisitUnaryDeref(UnaryOperator *E);
-  // FIXME: Missing: __extension__, __real__, __imag__, __builtin_choose_expr
+  APValue VisitUnaryExtension(const UnaryOperator *E)
+    { return Visit(E->getSubExpr()); }
+  APValue VisitChooseExpr(const ChooseExpr *E)
+    { return Visit(E->getChosenSubExpr(Info.Ctx)); }
+  // FIXME: Missing: __real__, __imag__
 };
 } // end anonymous namespace
 
@@ -285,8 +289,9 @@
   APValue VisitImplicitValueInitExpr(ImplicitValueInitExpr *E)
       { return APValue((Expr*)0, 0); }
   APValue VisitConditionalOperator(ConditionalOperator *E);
-  APValue VisitChooseExpr(ChooseExpr *E);
-  // FIXME: Missing: @encode, @protocol, @selector
+  APValue VisitChooseExpr(ChooseExpr *E)
+    { return Visit(E->getChosenSubExpr(Info.Ctx)); }
+  // FIXME: Missing: @protocol, @selector
 };
 } // end anonymous namespace
 
@@ -375,7 +380,6 @@
     return APValue();
   }
 
-  //assert(0 && "Unhandled cast");
   return APValue();
 }  
 
@@ -399,13 +403,6 @@
   return APValue();
 }
 
-APValue PointerExprEvaluator::VisitChooseExpr(ChooseExpr *E) {
-  APValue Result;
-  if (EvaluatePointer(E->getChosenSubExpr(Info.Ctx), Result, Info))
-    return Result;
-  return APValue();
-}
-
 //===----------------------------------------------------------------------===//
 // Vector Evaluation
 //===----------------------------------------------------------------------===//
@@ -437,7 +434,8 @@
     APValue VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
     APValue VisitInitListExpr(const InitListExpr *E);
     APValue VisitConditionalOperator(const ConditionalOperator *E);
-    APValue VisitChooseExpr(const ChooseExpr *E);
+    APValue VisitChooseExpr(const ChooseExpr *E)
+      { return Visit(E->getChosenSubExpr(Info.Ctx)); }
     APValue VisitUnaryImag(const UnaryOperator *E);
     // FIXME: Missing: unary -, unary ~, binary add/sub/mul/div,
     //                 binary comparisons, binary and/or/xor,
@@ -530,13 +528,6 @@
   return APValue();
 }
 
-APValue VectorExprEvaluator::VisitChooseExpr(const ChooseExpr *E) {
-  APValue Result;
-  if (EvaluateVector(E->getChosenSubExpr(Info.Ctx), Result, Info))
-    return Result;
-  return APValue();
-}
-
 APValue VectorExprEvaluator::VisitUnaryImag(const UnaryOperator *E) {
   if (!E->getSubExpr()->isEvaluatable(Info.Ctx))
     Info.EvalResult.HasSideEffects = true;
@@ -651,7 +642,10 @@
     return Success(E->EvaluateTrait(), E);
   }
 
-  bool VisitChooseExpr(const ChooseExpr *E);
+  bool VisitChooseExpr(const ChooseExpr *E) {
+    return Visit(E->getChosenSubExpr(Info.Ctx));
+  }
+
   bool VisitUnaryReal(const UnaryOperator *E);
   bool VisitUnaryImag(const UnaryOperator *E);
 
@@ -1193,10 +1187,6 @@
   return Success(HandleFloatToIntCast(DestType, SrcType, F, Info.Ctx), E);
 }
 
-bool IntExprEvaluator::VisitChooseExpr(const ChooseExpr *E) {
-  return Visit(E->getChosenSubExpr(Info.Ctx));
-}
-
 bool IntExprEvaluator::VisitUnaryReal(const UnaryOperator *E) {
   if (E->getSubExpr()->getType()->isAnyComplexType()) {
     APValue LV;
@@ -1247,9 +1237,13 @@
   bool VisitCastExpr(CastExpr *E);
   bool VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
 
-  // FIXME: Missing: __real__/__imag__, __extension__, 
-  //                 array subscript of vector, member of vector, 
-  //                 __builtin_choose_expr, ImplicitValueInitExpr,
+  bool VisitChooseExpr(const ChooseExpr *E)
+    { return Visit(E->getChosenSubExpr(Info.Ctx)); }
+  bool VisitUnaryExtension(const UnaryOperator *E)
+    { return Visit(E->getSubExpr()); }
+
+  // FIXME: Missing: __real__/__imag__, array subscript of vector,
+  //                 member of vector, ImplicitValueInitExpr,
   //                 conditional ?:, comma
 };
 } // end anonymous namespace
@@ -1510,8 +1504,11 @@
   }
   
   APValue VisitBinaryOperator(const BinaryOperator *E);
-  // FIXME Missing: unary +/-/~, __extension__, binary div,
-  //                __builtin_choose_expr, ImplicitValueInitExpr,
+  APValue VisitChooseExpr(const ChooseExpr *E)
+    { return Visit(E->getChosenSubExpr(Info.Ctx)); }
+  APValue VisitUnaryExtension(const UnaryOperator *E)
+    { return Visit(E->getSubExpr()); }
+  // FIXME Missing: unary +/-/~, binary div, ImplicitValueInitExpr,
   //                conditional ?:, comma
 };
 } // end anonymous namespace





More information about the cfe-commits mailing list