LLVM  7.0.0svn
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 //===----------------------------------------------------------------------===//
10 #include "SyntaxHighlighting.h"
14 using namespace llvm;
15 using namespace dwarf;
16 using namespace syntax;
19  UseColor("color",
20  cl::desc("use colored syntax highlighting (default=autodetect)"),
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  case Error: OS.changeColor(raw_ostream::RED, true); break;
34  case Warning: OS.changeColor(raw_ostream::MAGENTA, true); break;
35  case Note: OS.changeColor(raw_ostream::BLACK, true); break;
36  }
37  }
38 }
42  OS.resetColor();
43 }
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
WithColor(raw_ostream &OS, enum HighlightColor Type)
To be used like this: WithColor(OS, syntax::String) << "text";.
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:252
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:406
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 bool has_colors() const
This function determines if this stream is displayed and supports colors.
Definition: raw_ostream.h:274
virtual raw_ostream & resetColor()
Resets the colors to terminal defaults.
Definition: raw_ostream.h:263
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44