Some minor improvements to Evaluate.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65613 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 5cfc6e6..4f55f8d 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -636,16 +636,24 @@
return Success(0, E);
}
+ bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E) {
+ return Success(0, E);
+ }
+
bool VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *E) {
return Success(E->EvaluateTrait(), E);
}
+ bool VisitChooseExpr(const ChooseExpr *E);
+ bool VisitUnaryReal(const UnaryOperator *E) {
+ return Visit(E->getSubExpr());
+ }
+ bool VisitUnaryImag(const UnaryOperator *E);
+
private:
unsigned GetAlignOfExpr(const Expr *E);
unsigned GetAlignOfType(QualType T);
- // FIXME: Missing: __real__/__imag__, array subscript of vector,
- // member of vector, __builtin_choose_expr,
- // ImplicitValueInitExpr
+ // FIXME: Missing: array subscript of vector, member of vector
};
} // end anonymous namespace
@@ -1170,6 +1178,18 @@
return Success(HandleFloatToIntCast(DestType, SrcType, F, Info.Ctx), E);
}
+bool IntExprEvaluator::VisitChooseExpr(const ChooseExpr *E) {
+ Expr* EvalExpr = E->isConditionTrue(Info.Ctx) ? E->getLHS() : E->getRHS();
+
+ return Visit(EvalExpr);
+}
+
+bool IntExprEvaluator::VisitUnaryImag(const UnaryOperator *E) {
+ if (!E->getSubExpr()->isEvaluatable(Info.Ctx))
+ Info.EvalResult.HasSideEffects = true;
+ return Success(0, E);
+}
+
//===----------------------------------------------------------------------===//
// Float Evaluation
//===----------------------------------------------------------------------===//