diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-10-06 06:31:58 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-10-06 06:31:58 +0000 |
| commit | 0b7282eafc08ca4b40cf364ee772c52ab6428b2a (patch) | |
| tree | f4127cd9163a96ffe0e913bca1d7032f0818383f /clang/lib/AST/ExprConstant.cpp | |
| parent | a1518b1dfe63f459cafb38394c4728fb96643b31 (diff) | |
| download | bcm5719-llvm-0b7282eafc08ca4b40cf364ee772c52ab6428b2a.tar.gz bcm5719-llvm-0b7282eafc08ca4b40cf364ee772c52ab6428b2a.zip | |
Move handling of __builtin_nan("") out of CGBuiltin.cpp into ExprConstant.cpp
llvm-svn: 57157
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index c20cf4c0c5a..2b92cc73556 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -556,6 +556,20 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) { case Builtin::BI__builtin_infl: Result = llvm::APFloat::getInf(Sem); return true; + + case Builtin::BI__builtin_nan: + case Builtin::BI__builtin_nanf: + case Builtin::BI__builtin_nanl: + // If this is __builtin_nan("") turn this into a simple nan, otherwise we + // can't constant fold it. + if (const StringLiteral *S = + dyn_cast<StringLiteral>(E->getArg(0)->IgnoreParenCasts())) { + if (!S->isWide() && S->getByteLength() == 0) { // empty string. + Result = llvm::APFloat::getNaN(Sem); + return true; + } + } + return false; } } |

