[PATCH] Teach llvm::format_hex() to support formatting without a prefix '0x'

Zachary Turner zturner at google.com
Sat Jan 24 09:09:51 PST 2015


Fwiw, the default value of 4th arg is true already, so it's unnecessary. As
of my latest patch i moved no prefix mode to a separate function, so
printing with/without prefix is now

OS << format_hex(N, 16) // 0x12345
vs.
OS << format_hex_no_prefix(N, 16) // 12345

It does seem a bit clearer if we change it, but i was worried that it would
break external users in ways that would only be visible at runtime, which
is much worse than breaking them at compile time
On Sat, Jan 24, 2015 at 8:17 AM Sean Silva <chisophugis at gmail.com> wrote:

> On Fri, Jan 23, 2015 at 10:00 PM, Chandler Carruth <chandlerc at google.com>
> wrote:
>
>>
>> On Fri, Jan 23, 2015 at 1:58 PM, Rui Ueyama <ruiu at google.com> wrote:
>>
>>> Why does format_hex prints out "0x" prefix in the first place? If it
>>> doesn't, like printf %x, we don't need an extra parameter or a separate
>>> function. It may be too late, though.
>>
>>
>> I would be fine to change all users to just write '0x' into the stream
>> first.
>>
>
> +1. Compare:
>
> OS << format_hex(N, 16, false, true);
> vs.
> OS << "0x" << format_hex(N, 16);
>
> -- Sean Silva
>
>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150124/89799623/attachment.html>


More information about the llvm-commits mailing list