[llvm-commits] CVS: llvm/include/llvm/Support/Debug.h

Bill Wendling isanbard at gmail.com
Thu Nov 16 17:44:26 PST 2006


On 11/16/06, Reid Spencer <rspencer at reidspencer.com> wrote:
> On Thu, 2006-11-16 at 18:49 -0600, Bill Wendling wrote:
> > Added "DOUT" macro. This is used as a replacement for the std::cerr
> > stream. It centralizes the use of std::cerr so that static c'tor/d'tors
> > aren't scattered around all over the place. The way to use it is like this:
> >
> >        DOUT << "This is a status line: " << Var << "\n";
> >
> > If "-debug" is specified, it will print. Otherwise, it'll not print. If
> > NDEBUG is defined, the DOUT does nothing.
>
> While this may not print anything when NDEBUG is *not* defined, it isn't
> sufficient. You're going to leave template functions scattered all over
> the place and calls to them. The existing solution completely eliminates
> the code from an NDEBUG build. That's what we want. What's wrong with
> the existing solution?  Or, perhaps a combination is needed. Something
> like:
>
> DEBUG(DOUT << "This is a debug message\n");
>
Hi Reid,

Basically, this is to get rid of static c'tor/d'tors scattered all
over the source tree. (You get them whenever you #include <iostream>.)
A smart compiler should be able to remove all of the empty functions
because they don't have any side-effects.

-bw



More information about the llvm-commits mailing list