diff options
author | Anders Carlsson <andersca@mac.com> | 2008-12-19 20:58:05 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-12-19 20:58:05 +0000 |
commit | 1c0cfd4599e816cfd7a8f348286bf0ad79652ffc (patch) | |
tree | f4596e1bd04d54571b355824f66b0a0fe6acb437 /lib/AST | |
parent | 06c58b191f969e2ae5308cc9b6540bad9511f4ef (diff) |
Get rid of the old Expr::Evaluate variant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/Expr.cpp | 8 | ||||
-rw-r--r-- | lib/AST/ExprConstant.cpp | 21 |
2 files changed, 9 insertions, 20 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index c01c973cf5..8aaea7ac9f 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -763,9 +763,11 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, // If this is a call to a builtin function, constant fold it otherwise // reject it. if (CE->isBuiltinCall()) { - APValue ResultAP; - if (CE->Evaluate(ResultAP, Ctx)) { - Result = ResultAP.getInt(); + EvalResult EvalResult; + if (CE->Evaluate(EvalResult, Ctx)) { + assert(!EvalResult.HasSideEffects && + "Foldable builtin call should not have side effects!"); + Result = EvalResult.Val.getInt(); break; // It is a constant, expand it. } } diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 7a83d6c063..681016793f 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1194,19 +1194,6 @@ bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const { 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; -} - /// isEvaluatable - Call Evaluate to see if this expression can be constant /// folded, but discard the result. bool Expr::isEvaluatable(ASTContext &Ctx) const { @@ -1215,10 +1202,10 @@ bool Expr::isEvaluatable(ASTContext &Ctx) const { } APSInt Expr::EvaluateAsInt(ASTContext &Ctx) const { - APValue V; - bool Result = Evaluate(V, Ctx); + EvalResult EvalResult; + bool Result = Evaluate(EvalResult, Ctx); assert(Result && "Could not evaluate expression"); - assert(V.isInt() && "Expression did not evaluate to integer"); + assert(EvalResult.Val.isInt() && "Expression did not evaluate to integer"); - return V.getInt(); + return EvalResult.Val.getInt(); } |