From 7cbed03c00e246682e5292785d01e1c120ce54bd Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 14 Oct 2008 05:41:12 +0000 Subject: [PATCH] Fix test suite regression, getFloatTypeSemantics shouldn't be called on non-float types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57477 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ExprConstant.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 2b94964a91..cc2b4e6735 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -596,9 +596,6 @@ static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) { } bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { - const llvm::fltSemantics &Sem = - Info.Ctx.getFloatTypeSemantics(E->getType()); - switch (E->isBuiltinCall()) { default: return false; case Builtin::BI__builtin_huge_val: @@ -606,9 +603,12 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { case Builtin::BI__builtin_huge_vall: case Builtin::BI__builtin_inf: case Builtin::BI__builtin_inff: - case Builtin::BI__builtin_infl: + case Builtin::BI__builtin_infl: { + const llvm::fltSemantics &Sem = + Info.Ctx.getFloatTypeSemantics(E->getType()); Result = llvm::APFloat::getInf(Sem); return true; + } case Builtin::BI__builtin_nan: case Builtin::BI__builtin_nanf: @@ -618,6 +618,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { if (const StringLiteral *S = dyn_cast(E->getArg(0)->IgnoreParenCasts())) { if (!S->isWide() && S->getByteLength() == 0) { // empty string. + const llvm::fltSemantics &Sem = + Info.Ctx.getFloatTypeSemantics(E->getType()); Result = llvm::APFloat::getNaN(Sem); return true; } -- 2.40.0