[cfe-commits] Fwd: [cfe-dev] [PATCH] rewrite floats more precisely
Joerg Sonnenberger
joerg at britannica.bec.de
Thu Sep 20 06:25:36 PDT 2012
On Thu, Aug 09, 2012 at 12:39:16PM +0200, Olaf Krzikalla wrote:
> Index: lib/AST/StmtPrinter.cpp
> ===================================================================
> --- lib/AST/StmtPrinter.cpp (revision 160546)
> +++ lib/AST/StmtPrinter.cpp (working copy)
> @@ -735,6 +740,19 @@
> SmallString<16> Str;
> Node->getValue().toString(Str);
> OS << Str;
> + if (Str.find_first_not_of("-0123456789") == std::string::npos)
> + {
> + OS << "."; // trailing dot in order to separate from ints
> + }
> +
> + // Emit suffixes. Float literals are always a builtin float type.
> + switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
> + default: llvm_unreachable("Unexpected type for float literal!");
> + case BuiltinType::Half: break; // FIXME: suffix?
> + case BuiltinType::Double: break; // no suffix.
> + case BuiltinType::Float: OS << 'F'; break;
> + case BuiltinType::LongDouble: OS << 'L'; break;
> + }
> }
>
> void StmtPrinter::VisitImaginaryLiteral(ImaginaryLiteral *Node) {
LGTM
More information about the cfe-commits
mailing list