]> granicus.if.org Git - clang/commitdiff
adjust to a change in the LLVM APIs, this is still very hackish until
authorChris Lattner <sabre@nondot.org>
Thu, 13 Sep 2007 01:26:11 +0000 (01:26 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 13 Sep 2007 01:26:11 +0000 (01:26 +0000)
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

CodeGen/CGExprScalar.cpp

index 9c2e55f6eae337c63eae9642b5c4fc77b1840d96..62137b03b7d42d19424c5d8494be18ba27c7b592 100644 (file)
@@ -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());