Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libompd / src / Debug.h
blob18a3c7bb1d24946aa695a7a6414702a4246bf14d
1 /*
2 * Debug.h -- OMP debug
3 */
5 //===----------------------------------------------------------------------===//
6 //
7 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
8 // See https://llvm.org/LICENSE.txt for license information.
9 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 //===----------------------------------------------------------------------===//
13 #include <iostream>
14 #include <ostream>
16 #ifndef GDB_DEBUG_H_
17 #define GDB_DEBUG_H_
19 namespace GdbColor {
20 enum Code {
21 FG_RED = 31,
22 FG_GREEN = 32,
23 FG_BLUE = 34,
24 FG_DEFAULT = 39,
25 BG_RED = 41,
26 BG_GREEN = 42,
27 BG_BLUE = 44,
28 BG_DEFAULT = 49
30 inline std::ostream &operator<<(std::ostream &os, Code code) {
31 return os << "\033[" << static_cast<int>(code) << "m";
33 } // namespace GdbColor
35 class ColorOut {
36 private:
37 std::ostream &out;
38 GdbColor::Code color;
40 public:
41 ColorOut(std::ostream &_out, GdbColor::Code _color)
42 : out(_out), color(_color) {}
43 template <typename T> const ColorOut &operator<<(const T &val) const {
44 out << color << val << GdbColor::FG_DEFAULT;
45 return *this;
47 const ColorOut &operator<<(std::ostream &(*pf)(std::ostream &)) const {
48 out << color << pf << GdbColor::FG_DEFAULT;
49 return *this;
53 static ColorOut dout(std::cout, GdbColor::FG_RED);
54 static ColorOut sout(std::cout, GdbColor::FG_GREEN);
55 static ColorOut hout(std::cout, GdbColor::FG_BLUE);
57 #endif /*GDB_DEBUG_H_*/