[LLVMdev] Outputting hex in DOUT's

Daniel Dunbar daniel at zuster.org
Tue Aug 4 17:16:11 PDT 2009


On Tue, Aug 4, 2009 at 4:35 PM, David Greene<dag at cray.com> wrote:
> On Tuesday 04 August 2009 18:24, Chris Lattner wrote:
>
>> The big issue is things like this:
>>
>>    DOUT << foo.getName() << "\n";
>>
>> When -debug is disable and even when assertions are turned off,
>> foo.getName() is still called.  When you use:
>
> Yep, that's a problem.
>
>> DEBUG(errs() << foo.getName() << "\n");
>>
>> When assertions are turned off, the call doesn't exist.  It is also a
>> lot less "magic".
>
> Why doesn't
>
> DEBUG(DOUT << foo.getName() << "\n");
>
> work?  That's how I've always done it.  A bit redundant perhaps, but it works.

It is redundant, if you are using DEBUG there is no reason to provide
DOUT. And we didn't want to replicate the DOUT behavior for
raw_ostream, since it is was too much magic (and could hide
performance issues).

I didn't explicitly document that DOUT was deprecated, but I did
update the documentation here:
  http://llvm.org/docs/ProgrammersManual.html#DEBUG
and put some comments in the 2.6 release notes about changing DOUT to DEBUG.

The main missing feature, which sparked this discussion, is the lack
of formatted output. Most clients don't use this, and we do have
llvm/Support/Format.h, so the hope is the move to DEBUG(errs ...) is
largely mechanical.

 - Daniel




More information about the llvm-dev mailing list