| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | #ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H |
| 14 | #define LLVM_CLANG_AST_ASTDUMPERUTILS_H |
| 15 | |
| 16 | #include "llvm/Support/raw_ostream.h" |
| 17 | |
| 18 | namespace clang { |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | struct TerminalColor { |
| 24 | llvm::raw_ostream::Colors Color; |
| 25 | bool Bold; |
| 26 | }; |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | static const TerminalColor DeclKindNameColor = {llvm::raw_ostream::GREEN, true}; |
| 40 | |
| 41 | static const TerminalColor AttrColor = {llvm::raw_ostream::BLUE, true}; |
| 42 | |
| 43 | static const TerminalColor StmtColor = {llvm::raw_ostream::MAGENTA, true}; |
| 44 | |
| 45 | static const TerminalColor = {llvm::raw_ostream::BLUE, false}; |
| 46 | |
| 47 | |
| 48 | static const TerminalColor TypeColor = {llvm::raw_ostream::GREEN, false}; |
| 49 | |
| 50 | |
| 51 | static const TerminalColor AddressColor = {llvm::raw_ostream::YELLOW, false}; |
| 52 | |
| 53 | static const TerminalColor LocationColor = {llvm::raw_ostream::YELLOW, false}; |
| 54 | |
| 55 | |
| 56 | static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false}; |
| 57 | |
| 58 | static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false}; |
| 59 | |
| 60 | |
| 61 | static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false}; |
| 62 | |
| 63 | |
| 64 | static const TerminalColor UndeserializedColor = {llvm::raw_ostream::GREEN, |
| 65 | true}; |
| 66 | |
| 67 | |
| 68 | static const TerminalColor CastColor = {llvm::raw_ostream::RED, false}; |
| 69 | |
| 70 | |
| 71 | static const TerminalColor ValueColor = {llvm::raw_ostream::CYAN, true}; |
| 72 | |
| 73 | static const TerminalColor DeclNameColor = {llvm::raw_ostream::CYAN, true}; |
| 74 | |
| 75 | |
| 76 | static const TerminalColor IndentColor = {llvm::raw_ostream::BLUE, false}; |
| 77 | |
| 78 | class ColorScope { |
| 79 | llvm::raw_ostream &OS; |
| 80 | const bool ShowColors; |
| 81 | |
| 82 | public: |
| 83 | ColorScope(llvm::raw_ostream &OS, bool ShowColors, TerminalColor Color) |
| 84 | : OS(OS), ShowColors(ShowColors) { |
| 85 | if (ShowColors) |
| 86 | OS.changeColor(Color.Color, Color.Bold); |
| 87 | } |
| 88 | ~ColorScope() { |
| 89 | if (ShowColors) |
| 90 | OS.resetColor(); |
| 91 | } |
| 92 | }; |
| 93 | |
| 94 | } |
| 95 | |
| 96 | #endif |
| 97 | |