LLVM  5.0.0
SyntaxHighlighting.cpp
Go to the documentation of this file.
1 //===- SyntaxHighlighting.cpp ---------------------------------------------===//
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 #include "SyntaxHighlighting.h"
13 
14 using namespace llvm;
15 using namespace dwarf;
16 using namespace syntax;
17 
19  UseColor("color",
20  cl::desc("use colored syntax highlighting (default=autodetect)"),
22 
24  // Detect color from terminal type unless the user passed the --color option.
26  switch (Type) {
27  case Address: OS.changeColor(raw_ostream::YELLOW); break;
28  case String: OS.changeColor(raw_ostream::GREEN); break;
29  case Tag: OS.changeColor(raw_ostream::BLUE); break;
30  case Attribute: OS.changeColor(raw_ostream::CYAN); break;
32  case Macro: OS.changeColor(raw_ostream::RED); break;
33  }
34  }
35 }
36 
39  OS.resetColor();
40 }
WithColor(raw_ostream &OS, enum HighlightColor Type)
To be used like this: WithColor(OS, syntax::String) << "text";.
Attribute
Attributes.
Definition: Dwarf.h:105
virtual bool has_colors() const
This function determines if this stream is displayed and supports colors.
Definition: raw_ostream.h:270
virtual raw_ostream & changeColor(enum Colors Color, bool Bold=false, bool BG=false)
Changes the foreground color of text that will be output from this point forward. ...
Definition: raw_ostream.h:248
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:401
static cl::opt< cl::boolOrDefault > UseColor("color", cl::desc("use colored syntax highlighting (default=autodetect)"), cl::init(cl::BOU_UNSET))
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
virtual raw_ostream & resetColor()
Resets the colors to terminal defaults.
Definition: raw_ostream.h:259
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44