From: Chris Lattner Date: Thu, 13 Sep 2007 01:26:11 +0000 (+0000) Subject: adjust to a change in the LLVM APIs, this is still very hackish until X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=191396c96db9edd2abec9d1d789f39a5cbee81f6;p=clang adjust to a change in the LLVM APIs, this is still very hackish until the front-end adopts APFloat though. This fixes test/CodeGen/mandel.c git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41908 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/CodeGen/CGExprScalar.cpp b/CodeGen/CGExprScalar.cpp index 9c2e55f6ea..62137b03b7 100644 --- a/CodeGen/CGExprScalar.cpp +++ b/CodeGen/CGExprScalar.cpp @@ -93,7 +93,13 @@ public: return llvm::ConstantInt::get(E->getValue()); } Value *VisitFloatingLiteral(const FloatingLiteral *E) { - return llvm::ConstantFP::get(ConvertType(E->getType()), E->getValue()); + double V = E->getValue(); + // FIXME: Change this when FloatingLiteral uses an APFloat internally. + const llvm::Type *Ty = ConvertType(E->getType()); + if (Ty == llvm::Type::FloatTy) + return llvm::ConstantFP::get(Ty, llvm::APFloat((float)V)); + assert(Ty == llvm::Type::DoubleTy && "Unknown float type!"); + return llvm::ConstantFP::get(Ty, llvm::APFloat((double)V)); } Value *VisitCharacterLiteral(const CharacterLiteral *E) { return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());