[cfe-commits] r42235 - in /cfe/trunk: Basic/TargetInfo.cpp Lex/LiteralSupport.cpp include/clang/AST/Expr.h
Chris Lattner
sabre at nondot.org
Sat Sep 22 11:38:32 PDT 2007
Author: lattner
Date: Sat Sep 22 13:38:30 2007
New Revision: 42235
URL: http://llvm.org/viewvc/llvm-project?rev=42235&view=rev
Log:
work around bugs and missing features in apfloat.
Modified:
cfe/trunk/Basic/TargetInfo.cpp
cfe/trunk/Lex/LiteralSupport.cpp
cfe/trunk/include/clang/AST/Expr.h
Modified: cfe/trunk/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/TargetInfo.cpp?rev=42235&r1=42234&r2=42235&view=diff
==============================================================================
--- cfe/trunk/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/Basic/TargetInfo.cpp Sat Sep 22 13:38:30 2007
@@ -42,8 +42,10 @@
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;
}
Modified: cfe/trunk/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/LiteralSupport.cpp?rev=42235&r1=42234&r2=42235&view=diff
==============================================================================
--- cfe/trunk/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/Lex/LiteralSupport.cpp Sat Sep 22 13:38:30 2007
@@ -409,13 +409,20 @@
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,
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=42235&r1=42234&r2=42235&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Sep 22 13:38:30 2007
@@ -223,7 +223,12 @@
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); }
More information about the cfe-commits
mailing list