Home | History | Annotate | Download | only in sanitizer_common
      1 //===-- sanitizer_report_decorator.h ----------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // Tags to decorate the sanitizer reports.
     11 // Currently supported tags:
     12 //   * None.
     13 //   * ANSI color sequences.
     14 //
     15 //===----------------------------------------------------------------------===//
     16 
     17 #ifndef SANITIZER_REPORT_DECORATOR_H
     18 #define SANITIZER_REPORT_DECORATOR_H
     19 
     20 namespace __sanitizer {
     21 class AnsiColorDecorator {
     22  public:
     23   explicit AnsiColorDecorator(bool use_ansi_colors) : ansi_(use_ansi_colors) { }
     24   const char *Bold()    const { return ansi_ ? "\033[1m" : ""; }
     25   const char *Black()   const { return ansi_ ? "\033[1m\033[30m" : ""; }
     26   const char *Red()     const { return ansi_ ? "\033[1m\033[31m" : ""; }
     27   const char *Green()   const { return ansi_ ? "\033[1m\033[32m" : ""; }
     28   const char *Yellow()  const { return ansi_ ? "\033[1m\033[33m" : ""; }
     29   const char *Blue()    const { return ansi_ ? "\033[1m\033[34m" : ""; }
     30   const char *Magenta() const { return ansi_ ? "\033[1m\033[35m" : ""; }
     31   const char *Cyan()    const { return ansi_ ? "\033[1m\033[36m" : ""; }
     32   const char *White()   const { return ansi_ ? "\033[1m\033[37m" : ""; }
     33   const char *Default() const { return ansi_ ? "\033[1m\033[0m"  : ""; }
     34  private:
     35   bool ansi_;
     36 };
     37 }  // namespace __sanitizer
     38 
     39 #endif  // SANITIZER_REPORT_DECORATOR_H
     40