[cfe-dev] using raw_ostream in ASTConsumers

Chris Lattner clattner at apple.com
Sat Aug 23 11:35:13 PDT 2008

On Aug 23, 2008, at 3:33 AM, Csaba Hruska wrote:
> I've started porting to raw_ostream.

Ok, if there are pieces that can be moved over without any roadblocks,  
it would be useful to move those over in pieces, instead of doing one  
"big bang" patch.

> 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?

> - 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  

> One more thing: In many cases ostringstream is used. Should we  
> always wrap this ostream with raw_os_ostream or is there a better  
> solution ?

It is probably best to add a raw_string_stream that directly  
concatenates the output into a string.


More information about the cfe-dev mailing list