[LLVMdev] Fixed with hex numbers with raw_ostream
Nick Kledzik
kledzik at apple.com
Fri May 18 11:50:17 PDT 2012
I've been using the nifty:
DEBUG(errs() << "Here is the state of things:\n");
style of optional logging, but ran into an issue where I want to dump a table of information. The problem is getting the columns to line up, since the raw_ostream methods write numbers as variable length.
I've worked up a patch that adds two new methods to raw_ostream:
/// write_hex - Output \arg N as ten char hexadecimal string, including
/// 0x prefix (e.g. 0x12345678 or 0x00000001).
raw_ostream &write_hex32(uint32_t N);
/// write_hex - Output \arg N as 18 char hexadecimal string, including
/// 0x prefix (e.g. 0x0123456789abcdef or 0x0000000000000001).
raw_ostream &write_hex64(uint64_t N);
Is there already some way to do this level of formatting with raw_ostream?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raw_ostream.patch
Type: application/octet-stream
Size: 2143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120518/f81a985c/attachment.obj>
-------------- next part --------------
-Nick
More information about the llvm-dev
mailing list