debug macros

Their are a pair of debug macros I use in almost every project I work on and I would like to add them to LLVM if acceptable.

The existing DEBUG macro is good for a lot of things, but inadequate for certain situations. The may be cases where you wan’t to run calculations in the debug version that lead up to assertions. In a scenario like this, you will likely need a temporary variable, and you calculations need to execute unconditionally.

For this type of scenario I use the _dbg macro:

#ifndef NDEBUG
#define _dbg(x) x
#else
#define _dbg(x)
#endif

The other macro is just a slight variation on the existing DEBUG macro, but for the common case of printing something out to the debug console, its simpler to write, and in my opinion easier to read.

#define dbgout(x) DEBUG(dbgs()<<x)
#define dbgoutc(y,x) DEBUG_WITH_TYPE(x,dbgs()<<y)

-Nathan