view gen/logger.h @ 1316:8c65217be813

Work around an LLVM bug by not referring to globals from metadata. This was only used for consistency checking anyway. For the LLVM bug, see http://llvm.org/PR4180 / http://llvm.org/PR4046
author Frits van Bommel <fvbommel wxs.nl>
date Fri, 08 May 2009 16:00:44 +0200
parents 79758fd2f48a
children 229e02867307
line wrap: on
line source

#ifndef _llvmd_gen_logger_h_
#define _llvmd_gen_logger_h_

#include "llvm/Support/Streams.h"

struct Loc;

namespace Logger
{
    void indent();
    void undent();
    llvm::OStream cout();
    void println(const char* fmt, ...);
    void print(const char* fmt, ...);
    void enable();
    void disable();
    bool enabled();

    void attention(Loc loc, const char* fmt, ...);

    struct LoggerScope
    {
        LoggerScope()
        {
            Logger::indent();
        }
        ~LoggerScope()
        {
            Logger::undent();
        }
    };
}

#define LOG_SCOPE    Logger::LoggerScope _logscope;

#define IF_LOG       if (Logger::enabled())

#endif