[cfe-dev] using raw_ostream in ASTConsumers

Chris Lattner clattner at apple.com
Sat Aug 23 12:51:00 PDT 2008

On Aug 23, 2008, at 11:35 AM, Chris Lattner wrote:
>> I've found these problems:
>> - raw_stream is currently not supports pointer printing. << (void*)X
> This should be easy to add, just add a method to raw_stream?

I didn't add this, can you add it?

>> - not supports field width like: << std::setw(3) << ... (this is in
>> file: CFG.cpp line 1485)
>> - not supports hexa printing like: <<std::hex << value (this is in
>> file: StmtPrinter.cpp line 550)
> Adding a full set of formatting is a non-trival job, and we don't want
> to follow the lead of iostreams.  I'll see if I can hack something in
> quickly.

Okay, you can now do stuff like this:

OS << "whatever" << format("%4.3f some hex thing 0x%X", mydouble, 255)  
<< " blah";

This is efficient (no temporary strings etc), and you can use any  
(portable) printf formatting without penalty.


More information about the cfe-dev mailing list