Retro68/gcc/libsanitizer/sanitizer_common/sanitizer_report_decorator.h

48 lines
1.8 KiB
C
Raw Normal View History

2014-09-21 17:33:12 +00:00
//===-- sanitizer_report_decorator.h ----------------------------*- C++ -*-===//
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Tags to decorate the sanitizer reports.
// Currently supported tags:
// * None.
// * ANSI color sequences.
//
//===----------------------------------------------------------------------===//
#ifndef SANITIZER_REPORT_DECORATOR_H
#define SANITIZER_REPORT_DECORATOR_H
2015-08-28 15:33:40 +00:00
#include "sanitizer_common.h"
2014-09-21 17:33:12 +00:00
namespace __sanitizer {
2015-08-28 15:33:40 +00:00
class SanitizerCommonDecorator {
2014-09-21 17:33:12 +00:00
// FIXME: This is not portable. It assumes the special strings are printed to
// stdout, which is not the case on Windows (see SetConsoleTextAttribute()).
public:
2015-08-28 15:33:40 +00:00
SanitizerCommonDecorator() : ansi_(ColorizeReports()) {}
2019-06-02 15:48:37 +00:00
const char *Bold() const { return ansi_ ? "\033[1m" : ""; }
2015-08-28 15:33:40 +00:00
const char *Default() const { return ansi_ ? "\033[1m\033[0m" : ""; }
2018-12-28 15:30:48 +00:00
const char *Warning() const { return Red(); }
2019-06-02 15:48:37 +00:00
const char *Error() const { return Red(); }
const char *MemoryByte() const { return Magenta(); }
2018-12-28 15:30:48 +00:00
2015-08-28 15:33:40 +00:00
protected:
2014-09-21 17:33:12 +00:00
const char *Black() const { return ansi_ ? "\033[1m\033[30m" : ""; }
const char *Red() const { return ansi_ ? "\033[1m\033[31m" : ""; }
const char *Green() const { return ansi_ ? "\033[1m\033[32m" : ""; }
const char *Yellow() const { return ansi_ ? "\033[1m\033[33m" : ""; }
const char *Blue() const { return ansi_ ? "\033[1m\033[34m" : ""; }
const char *Magenta() const { return ansi_ ? "\033[1m\033[35m" : ""; }
const char *Cyan() const { return ansi_ ? "\033[1m\033[36m" : ""; }
const char *White() const { return ansi_ ? "\033[1m\033[37m" : ""; }
private:
bool ansi_;
};
2015-08-28 15:33:40 +00:00
2014-09-21 17:33:12 +00:00
} // namespace __sanitizer
#endif // SANITIZER_REPORT_DECORATOR_H