Add a new variant of Evaluate and reimplement the old Evaluate in terms of the new.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60298 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 05c0ceb..6623837 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -166,6 +166,8 @@
   /// any crazy technique (that has nothing to do with language standards) that
   /// we want to.  If this function returns true, it returns the folded constant
   /// in Result.
+  bool Evaluate(EvalResult &Result, ASTContext &Ctx) const;
+
   // FIXME: We should come up with a better API for the isEvaluated case.
   bool Evaluate(APValue& Result, ASTContext &Ctx, bool *isEvaluated = 0) const;
 
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 931eae2..d26ba8b 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -1160,33 +1160,43 @@
 /// any crazy technique (that has nothing to do with language standards) that
 /// we want to.  If this function returns true, it returns the folded constant
 /// in Result.
-bool Expr::Evaluate(APValue &Result, ASTContext &Ctx, bool *isEvaluated) const {
-  Expr::EvalResult EvalResult;
-  EvalInfo Info(Ctx, EvalResult);
+bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const {
+  EvalInfo Info(Ctx, Result);
 
   if (getType()->isIntegerType()) {
     llvm::APSInt sInt(32);
     if (!EvaluateInteger(this, sInt, Info))
       return false;
     
-    Result = APValue(sInt);
+    Result.Val = APValue(sInt);
   } else if (getType()->isPointerType()) {
-    if (!EvaluatePointer(this, Result, Info))
+    if (!EvaluatePointer(this, Result.Val, Info))
       return false;
   } else if (getType()->isRealFloatingType()) {
     llvm::APFloat f(0.0);
     if (!EvaluateFloat(this, f, Info))
       return false;
     
-    Result = APValue(f);
+    Result.Val = APValue(f);
   } else if (getType()->isComplexType()) {
-    if (!EvaluateComplexFloat(this, Result, Info))
+    if (!EvaluateComplexFloat(this, Result.Val, Info))
       return false;
   }  else
     return false;
 
+  return true;
+}
+
+bool Expr::Evaluate(APValue &Result, ASTContext &Ctx, bool *isEvaluated) const {
+  EvalResult EvalResult;
+  
+  if (!Evaluate(EvalResult, Ctx))
+    return false;
+  
+  Result = EvalResult.Val;
   if (isEvaluated)
     *isEvaluated = !EvalResult.HasSideEffects;
+  
   return true;
 }