diff options
author | Chris Lattner <sabre@nondot.org> | 2007-09-22 18:38:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-09-22 18:38:30 +0000 |
commit | 1c9bdaef20398390818e9114269cd9925534b89c (patch) | |
tree | a0742b64898aa641b1be96dc81219a541da0b7e0 | |
parent | 525a05093a4816af961fe2bc6b8a81c17e2e26c2 (diff) |
work around bugs and missing features in apfloat.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42235 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Basic/TargetInfo.cpp | 6 | ||||
-rw-r--r-- | Lex/LiteralSupport.cpp | 9 | ||||
-rw-r--r-- | include/clang/AST/Expr.h | 7 |
3 files changed, 18 insertions, 4 deletions
diff --git a/Basic/TargetInfo.cpp b/Basic/TargetInfo.cpp index 2b0af7ed24..2c476b8627 100644 --- a/Basic/TargetInfo.cpp +++ b/Basic/TargetInfo.cpp @@ -42,8 +42,10 @@ void TargetInfo::getDoubleInfo(uint64_t &Size, unsigned &Align, void TargetInfo::getLongDoubleInfo(uint64_t &Size, unsigned &Align, const llvm::fltSemantics *&Format, SourceLocation Loc) { - Size = 80; Align = 32; // FIXME: implement correctly. - Format = &llvm::APFloat::x87DoubleExtended; + Size = Align = 64; // FIXME: implement correctly. + Format = &llvm::APFloat::IEEEdouble; + //Size = 80; Align = 32; // FIXME: implement correctly. + //Format = &llvm::APFloat::x87DoubleExtended; } diff --git a/Lex/LiteralSupport.cpp b/Lex/LiteralSupport.cpp index 3449c2769a..ae4c1a8fde 100644 --- a/Lex/LiteralSupport.cpp +++ b/Lex/LiteralSupport.cpp @@ -409,13 +409,20 @@ bool NumericLiteralParser::GetIntegerValue(llvm::APInt &Val) { return OverflowOccurred; } -// GetFloatValue - Poor man's floatvalue (FIXME). llvm::APFloat NumericLiteralParser:: GetFloatValue(const llvm::fltSemantics &Format) { char floatChars[256]; strncpy(floatChars, ThisTokBegin, ThisTokEnd-ThisTokBegin); floatChars[ThisTokEnd-ThisTokBegin] = '\0'; +#if 0 + // This doesn't work yet. return llvm::APFloat(Format, floatChars); +#else + // FIXME: this is horrible! + llvm::APFloat V(strtod(floatChars, 0)); + V.convert(Format, llvm::APFloat::rmTowardZero); + return V; +#endif } void NumericLiteralParser::Diag(SourceLocation Loc, unsigned DiagID, diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 08b2b6c036..54228696ef 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -223,7 +223,12 @@ public: FloatingLiteral(const llvm::APFloat &V, QualType Type, SourceLocation L) : Expr(FloatingLiteralClass, Type), Value(V), Loc(L) {} - float getValue() const { return Value.convertToDouble(); } + float getValue() const { + if (cast<BuiltinType>(getType())->getKind() == BuiltinType::Float) + return Value.convertToFloat(); + else + return Value.convertToDouble(); + } virtual SourceRange getSourceRange() const { return SourceRange(Loc); } |