File indexing completed on 2026-05-10 08:36:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H
0014 #define LLVM_CLANG_AST_ASTDUMPERUTILS_H
0015
0016 #include "llvm/Support/raw_ostream.h"
0017
0018 namespace clang {
0019
0020
0021 enum ASTDumpOutputFormat {
0022 ADOF_Default,
0023 ADOF_JSON
0024 };
0025
0026
0027
0028
0029 struct TerminalColor {
0030 llvm::raw_ostream::Colors Color;
0031 bool Bold;
0032 };
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 static const TerminalColor DeclKindNameColor = {llvm::raw_ostream::GREEN, true};
0046
0047 static const TerminalColor AttrColor = {llvm::raw_ostream::BLUE, true};
0048
0049 static const TerminalColor StmtColor = {llvm::raw_ostream::MAGENTA, true};
0050
0051 static const TerminalColor CommentColor = {llvm::raw_ostream::BLUE, false};
0052
0053
0054 static const TerminalColor TypeColor = {llvm::raw_ostream::GREEN, false};
0055
0056
0057 static const TerminalColor AddressColor = {llvm::raw_ostream::YELLOW, false};
0058
0059 static const TerminalColor LocationColor = {llvm::raw_ostream::YELLOW, false};
0060
0061
0062 static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false};
0063
0064 static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false};
0065
0066 static const TerminalColor ErrorsColor = {llvm::raw_ostream::RED, true};
0067
0068
0069 static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false};
0070
0071
0072 static const TerminalColor UndeserializedColor = {llvm::raw_ostream::GREEN,
0073 true};
0074
0075
0076 static const TerminalColor CastColor = {llvm::raw_ostream::RED, false};
0077
0078
0079 static const TerminalColor ValueColor = {llvm::raw_ostream::CYAN, true};
0080
0081 static const TerminalColor DeclNameColor = {llvm::raw_ostream::CYAN, true};
0082
0083
0084 static const TerminalColor IndentColor = {llvm::raw_ostream::BLUE, false};
0085
0086 class ColorScope {
0087 llvm::raw_ostream &OS;
0088 const bool ShowColors;
0089
0090 public:
0091 ColorScope(llvm::raw_ostream &OS, bool ShowColors, TerminalColor Color)
0092 : OS(OS), ShowColors(ShowColors) {
0093 if (ShowColors)
0094 OS.changeColor(Color.Color, Color.Bold);
0095 }
0096 ~ColorScope() {
0097 if (ShowColors)
0098 OS.resetColor();
0099 }
0100 };
0101
0102 }
0103
0104 #endif