1 //===--- ASTDumperUtils.h - Printing of AST nodes -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements AST utilities for traversal down the tree.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H
15 #define LLVM_CLANG_AST_ASTDUMPERUTILS_H
17 #include "llvm/Support/raw_ostream.h"
21 // Colors used for various parts of the AST dump
22 // Do not use bold yellow for any text. It is hard to read on white screens.
24 struct TerminalColor {
25 llvm::raw_ostream::Colors Color;
31 // Bold Green - DeclKindNameColor, UndeserializedColor
32 // Yellow - AddressColor, LocationColor
33 // Blue - CommentColor, NullColor, IndentColor
34 // Bold Blue - AttrColor
35 // Bold Magenta - StmtColor
36 // Cyan - ValueKindColor, ObjectKindColor
37 // Bold Cyan - ValueColor, DeclNameColor
39 // Decl kind names (VarDecl, FunctionDecl, etc)
40 static const TerminalColor DeclKindNameColor = {llvm::raw_ostream::GREEN, true};
41 // Attr names (CleanupAttr, GuardedByAttr, etc)
42 static const TerminalColor AttrColor = {llvm::raw_ostream::BLUE, true};
43 // Statement names (DeclStmt, ImplicitCastExpr, etc)
44 static const TerminalColor StmtColor = {llvm::raw_ostream::MAGENTA, true};
45 // Comment names (FullComment, ParagraphComment, TextComment, etc)
46 static const TerminalColor CommentColor = {llvm::raw_ostream::BLUE, false};
48 // Type names (int, float, etc, plus user defined types)
49 static const TerminalColor TypeColor = {llvm::raw_ostream::GREEN, false};
52 static const TerminalColor AddressColor = {llvm::raw_ostream::YELLOW, false};
54 static const TerminalColor LocationColor = {llvm::raw_ostream::YELLOW, false};
57 static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false};
58 // bitfield/objcproperty/objcsubscript/vectorcomponent
59 static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false};
62 static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false};
64 // Undeserialized entities
65 static const TerminalColor UndeserializedColor = {llvm::raw_ostream::GREEN,
68 // CastKind from CastExpr's
69 static const TerminalColor CastColor = {llvm::raw_ostream::RED, false};
71 // Value of the statement
72 static const TerminalColor ValueColor = {llvm::raw_ostream::CYAN, true};
74 static const TerminalColor DeclNameColor = {llvm::raw_ostream::CYAN, true};
76 // Indents ( `, -. | )
77 static const TerminalColor IndentColor = {llvm::raw_ostream::BLUE, false};
80 llvm::raw_ostream &OS;
81 const bool ShowColors;
84 ColorScope(llvm::raw_ostream &OS, bool ShowColors, TerminalColor Color)
85 : OS(OS), ShowColors(ShowColors) {
87 OS.changeColor(Color.Color, Color.Bold);
97 #endif // LLVM_CLANG_AST_ASTDUMPERUTILS_H