Files
ldc/gen/logger.h
Frits van Bommel 76ae0b0ab6 Fix format-string bugs by adding __attribute__((__format__)) in all applicable
places and fixing all warnings my gcc produced.
Among other things, this should fix several segfaults (including one I just
ran into).
2009-05-17 00:15:25 +02:00

48 lines
885 B
C++

#ifndef _llvmd_gen_logger_h_
#define _llvmd_gen_logger_h_
#include "llvm/Support/Streams.h"
#ifndef IS_PRINTF
# ifdef __GNUC__
# define IS_PRINTF(FMTARG) __attribute((__format__ (__printf__, (FMTARG), (FMTARG)+1) ))
# else
# define IS_PRINTF(FMTARG)
# endif
#endif
struct Loc;
namespace Logger
{
void indent();
void undent();
llvm::OStream cout();
void println(const char* fmt, ...) IS_PRINTF(1);
void print(const char* fmt, ...) IS_PRINTF(1);
void enable();
void disable();
bool enabled();
void attention(Loc loc, const char* fmt, ...) IS_PRINTF(2);
struct LoggerScope
{
LoggerScope()
{
Logger::indent();
}
~LoggerScope()
{
Logger::undent();
}
};
}
#define LOG_SCOPE Logger::LoggerScope _logscope;
#define IF_LOG if (Logger::enabled())
#endif