From: Chris Lattner Date: Sun, 16 Nov 2008 21:24:15 +0000 (+0000) Subject: rename Expr::tryEvaluate to Expr::Evaluate. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ee7aa154e8bbb21a21254293410b944f78b0bfe;p=clang rename Expr::tryEvaluate to Expr::Evaluate. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59426 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 5255f18445..6e67f2853f 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -134,13 +134,13 @@ public: /// isConstantExpr - Return true if this expression is a valid constant expr. bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const; - /// tryEvaluate - Return true if this is a constant which we can fold using + /// Evaluate - Return true if this is a constant which we can fold using /// 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 tryEvaluate(APValue& Result, ASTContext &Ctx) const; + bool Evaluate(APValue& Result, ASTContext &Ctx) const; - /// isEvaluatable - Call tryEvaluate to see if this expression can be constant + /// isEvaluatable - Call Evaluate to see if this expression can be constant /// folded, but discard the result. bool isEvaluatable(ASTContext &Ctx) const; diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 871dc4bb77..29d9a11de7 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -798,7 +798,7 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, // reject it. if (CE->isBuiltinCall()) { APValue ResultAP; - if (CE->tryEvaluate(ResultAP, Ctx)) { + if (CE->Evaluate(ResultAP, Ctx)) { Result = ResultAP.getInt(); break; // It is a constant, expand it. } diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 86f7a2181e..625a414aa9 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -508,7 +508,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { // __builtin_constant_p always has one operand: it returns true if that // operand can be folded, false otherwise. APValue Res; - Result = E->getArg(0)->tryEvaluate(Res, Info.Ctx); + Result = E->getArg(0)->Evaluate(Res, Info.Ctx); return true; } } @@ -1094,14 +1094,14 @@ static bool EvaluateComplexFloat(const Expr *E, APValue &Result, EvalInfo &Info) } //===----------------------------------------------------------------------===// -// Top level TryEvaluate. +// Top level Expr::Evaluate method. //===----------------------------------------------------------------------===// -/// tryEvaluate - Return true if this is a constant which we can fold using +/// Evaluate - Return true if this is a constant which we can fold using /// 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::tryEvaluate(APValue &Result, ASTContext &Ctx) const { +bool Expr::Evaluate(APValue &Result, ASTContext &Ctx) const { EvalInfo Info(Ctx); if (getType()->isIntegerType()) { llvm::APSInt sInt(32); @@ -1127,9 +1127,9 @@ bool Expr::tryEvaluate(APValue &Result, ASTContext &Ctx) const { return false; } -/// isEvaluatable - Call tryEvaluate to see if this expression can be constant +/// isEvaluatable - Call Evaluate to see if this expression can be constant /// folded, but discard the result. bool Expr::isEvaluatable(ASTContext &Ctx) const { APValue V; - return tryEvaluate(V, Ctx); + return Evaluate(V, Ctx); } diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 98e70e892d..a8eb8f794b 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -39,7 +39,7 @@ static RValue EmitBinaryAtomic(CodeGenFunction& CFG, RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { // See if we can constant fold this builtin. If so, don't emit it at all. APValue Result; - if (E->tryEvaluate(Result, CGM.getContext())) { + if (E->Evaluate(Result, CGM.getContext())) { if (Result.isInt()) return RValue::get(llvm::ConstantInt::get(Result.getInt())); assert(Result.isFloat() && "Unsupported constant type"); diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 7b33fdbe8e..41379b5b4a 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -610,7 +610,7 @@ public: llvm::Constant *VisitCallExpr(const CallExpr *E) { APValue Result; - if (E->tryEvaluate(Result, CGM.getContext())) { + if (E->Evaluate(Result, CGM.getContext())) { if (Result.isInt()) return llvm::ConstantInt::get(Result.getInt()); if (Result.isFloat()) @@ -845,7 +845,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E, #ifdef USE_TRY_EVALUATE APValue V; - if (E->tryEvaluate(V, Context)) { + if (E->Evaluate(V, Context)) { // FIXME: Assert that the value doesn't have any side effects. switch (V.getKind()) { default: assert(0 && "unhandled value kind!"); diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index e6deaa7475..ff05f6e585 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -197,7 +197,7 @@ int CodeGenFunction::ConstantFoldsToSimpleInteger(const Expr *Cond) { // FIXME: Rename and handle conversion of other evaluatable things // to bool. - if (!Cond->tryEvaluate(V, getContext()) || !V.isInt()) + if (!Cond->Evaluate(V, getContext()) || !V.isInt()) return 0; // Not foldable or not integer. if (CodeGenFunction::ContainsLabel(Cond)) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index dd76e15c09..1ecaaa370a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1560,11 +1560,11 @@ bool Sema::CheckArithmeticConstantExpression(const Expr* Init) { // specified arm of the conditional to be a constant. This is a horrible // hack, but is require by real world code that uses __builtin_constant_p. APValue Val; - if (!Exp->getCond()->tryEvaluate(Val, Context)) { - // If the tryEvaluate couldn't fold it, CheckArithmeticConstantExpression + if (!Exp->getCond()->Evaluate(Val, Context)) { + // If Evaluate couldn't fold it, CheckArithmeticConstantExpression // won't be able to either. Use it to emit the diagnostic though. bool Res = CheckArithmeticConstantExpression(Exp->getCond()); - assert(Res && "tryEvaluate couldn't evaluate this constant?"); + assert(Res && "Evaluate couldn't evaluate this constant?"); return Res; } @@ -2494,7 +2494,7 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T, APValue Result; if (!VLATy->getSizeExpr() || - !VLATy->getSizeExpr()->tryEvaluate(Result, Context)) + !VLATy->getSizeExpr()->Evaluate(Result, Context)) return QualType(); assert(Result.isInt() && "Size expressions must be integers!");