]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/DebugInfo/DWARF/SyntaxHighlighting.h
MFC r343601:
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / DebugInfo / DWARF / SyntaxHighlighting.h
1 //===- SyntaxHighlighting.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 #ifndef LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
11 #define LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
12
13 namespace llvm {
14
15 class raw_ostream;
16
17 namespace dwarf {
18 namespace syntax {
19
20 // Symbolic names for various syntax elements.
21 enum HighlightColor {
22   Address,
23   String,
24   Tag,
25   Attribute,
26   Enumerator,
27   Macro,
28   Error,
29   Warning,
30   Note
31 };
32
33 /// An RAII object that temporarily switches an output stream to a
34 /// specific color.
35 class WithColor {
36   raw_ostream &OS;
37
38 public:
39   /// To be used like this: WithColor(OS, syntax::String) << "text";
40   WithColor(raw_ostream &OS, enum HighlightColor Type);
41   ~WithColor();
42
43   raw_ostream &get() { return OS; }
44   operator raw_ostream &() { return OS; }
45 };
46
47 } // end namespace syntax
48 } // end namespace dwarf
49
50 } // end namespace llvm
51
52 #endif // LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H