Line data Source code
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 : /// Determine whether colors should be displayed.
38 : bool colorsEnabled(raw_ostream &OS);
39 :
40 : public:
41 : /// To be used like this: WithColor(OS, syntax::String) << "text";
42 : WithColor(raw_ostream &OS, enum HighlightColor Type);
43 : ~WithColor();
44 :
45 54015 : raw_ostream &get() { return OS; }
46 30557 : operator raw_ostream &() { return OS; }
47 : };
48 :
49 : } // end namespace syntax
50 : } // end namespace dwarf
51 :
52 : } // end namespace llvm
53 :
54 : #endif // LLVM_LIB_DEBUGINFO_SYNTAXHIGHLIGHTING_H
|