LLVM
8.0.1
|
An RAII object that temporarily switches an output stream to a specific color. More...
#include "llvm/Support/WithColor.h"
Public Member Functions | |
WithColor (raw_ostream &OS, HighlightColor S, bool DisableColors=false) | |
To be used like this: WithColor(OS, HighlightColor::String) << "text";. More... | |
WithColor (raw_ostream &OS, raw_ostream::Colors Color=raw_ostream::SAVEDCOLOR, bool Bold=false, bool BG=false, bool DisableColors=false) | |
To be used like this: WithColor(OS, raw_ostream::Black) << "text";. More... | |
~WithColor () | |
raw_ostream & | get () |
operator raw_ostream & () | |
template<typename T > | |
WithColor & | operator<< (T &O) |
template<typename T > | |
WithColor & | operator<< (const T &O) |
bool | colorsEnabled () |
Determine whether colors are displayed. More... | |
WithColor & | changeColor (raw_ostream::Colors Color, bool Bold=false, bool BG=false) |
Change the color of text that will be output from this point forward. More... | |
WithColor & | resetColor () |
Reset the colors to terminal defaults. More... | |
Static Public Member Functions | |
static raw_ostream & | error () |
Convenience method for printing "error: " to stderr. More... | |
static raw_ostream & | warning () |
Convenience method for printing "warning: " to stderr. More... | |
static raw_ostream & | note () |
Convenience method for printing "note: " to stderr. More... | |
static raw_ostream & | remark () |
Convenience method for printing "remark: " to stderr. More... | |
static raw_ostream & | error (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false) |
Convenience method for printing "error: " to the given stream. More... | |
static raw_ostream & | warning (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false) |
Convenience method for printing "warning: " to the given stream. More... | |
static raw_ostream & | note (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false) |
Convenience method for printing "note: " to the given stream. More... | |
static raw_ostream & | remark (raw_ostream &OS, StringRef Prefix="", bool DisableColors=false) |
Convenience method for printing "remark: " to the given stream. More... | |
An RAII object that temporarily switches an output stream to a specific color.
Definition at line 38 of file WithColor.h.
WithColor::WithColor | ( | raw_ostream & | OS, |
HighlightColor | S, | ||
bool | DisableColors = false |
||
) |
To be used like this: WithColor(OS, HighlightColor::String) << "text";.
OS | The output stream |
S | Symbolic name for syntax element to color |
DisableColors | Whether to ignore color changes regardless of -color and support in OS |
Definition at line 22 of file WithColor.cpp.
References llvm::Address, llvm::Attribute, llvm::raw_ostream::BLACK, llvm::raw_ostream::BLUE, llvm::raw_ostream::changeColor(), colorsEnabled(), llvm::raw_ostream::CYAN, llvm::Enumerator, llvm::Error, llvm::raw_ostream::GREEN, llvm::Macro, llvm::raw_ostream::MAGENTA, llvm::Note, llvm::raw_ostream::RED, llvm::Remark, llvm::String, llvm::Tag, llvm::Warning, and llvm::raw_ostream::YELLOW.
|
inline |
To be used like this: WithColor(OS, raw_ostream::Black) << "text";.
OS | The output stream |
Color | ANSI color to use, the special SAVEDCOLOR can be used to change only the bold attribute, and keep colors untouched |
Bold | Bold/brighter text, default false |
BG | If true, change the background, default: change foreground |
DisableColors | Whether to ignore color changes regardless of -color and support in OS |
Definition at line 57 of file WithColor.h.
WithColor::~WithColor | ( | ) |
Definition at line 121 of file WithColor.cpp.
References resetColor().
WithColor & WithColor::changeColor | ( | raw_ostream::Colors | Color, |
bool | Bold = false , |
||
bool | BG = false |
||
) |
Change the color of text that will be output from this point forward.
Color | ANSI color to use, the special SAVEDCOLOR can be used to change only the bold attribute, and keep colors untouched |
Bold | Bold/brighter text, default false |
BG | If true, change the background, default: change foreground |
Definition at line 108 of file WithColor.cpp.
References llvm::raw_ostream::changeColor(), and colorsEnabled().
bool WithColor::colorsEnabled | ( | ) |
Determine whether colors are displayed.
Definition at line 100 of file WithColor.cpp.
References llvm::cl::BOU_TRUE, llvm::cl::BOU_UNSET, llvm::raw_ostream::has_colors(), and UseColor.
Referenced by changeColor(), resetColor(), and WithColor().
|
static |
Convenience method for printing "error: " to stderr.
Definition at line 61 of file WithColor.cpp.
References llvm::errs().
Referenced by llvm::DWARFContext::defaultErrorHandler(), llvm::DWARFContext::dump(), dumpAttribute(), dumpLoclistsSection(), llvm::DWARFDebugAranges::generate(), llvm::DWARFUnit::getCompilationDir(), llvm::DWARFVerifier::handleAccelTables(), llvm::DWARFDebugLoc::parse(), llvm::DWARFDebugLoc::parseOneLocationList(), llvm::DWARFDebugLoclists::parseOneLocationList(), llvm::SMDiagnostic::print(), and llvm::PrintError().
|
static |
Convenience method for printing "error: " to the given stream.
Definition at line 69 of file WithColor.cpp.
References llvm::StringRef::empty(), llvm::Error, and WithColor().
|
inline |
Definition at line 65 of file WithColor.h.
Referenced by llvm::DWARFDebugMacro::dump(), llvm::DWARFFormValue::dump(), and llvm::DWARFDie::dump().
|
static |
Convenience method for printing "note: " to stderr.
Definition at line 65 of file WithColor.cpp.
References llvm::errs().
Referenced by llvm::DWARFVerifier::handleAccelTables(), llvm::SMDiagnostic::print(), and llvm::mca::verifyOperands().
|
static |
Convenience method for printing "note: " to the given stream.
Definition at line 85 of file WithColor.cpp.
References llvm::StringRef::empty(), llvm::Note, and WithColor().
|
inline |
Definition at line 66 of file WithColor.h.
Definition at line 67 of file WithColor.h.
References llvm::RISCVFenceField::O.
Definition at line 71 of file WithColor.h.
References error, llvm::RISCVFenceField::O, llvm::cl::Prefix, and warning.
|
static |
Convenience method for printing "remark: " to stderr.
Definition at line 67 of file WithColor.cpp.
References llvm::errs().
Referenced by llvm::SMDiagnostic::print().
|
static |
Convenience method for printing "remark: " to the given stream.
Definition at line 92 of file WithColor.cpp.
References llvm::StringRef::empty(), llvm::Remark, and WithColor().
WithColor & WithColor::resetColor | ( | ) |
Reset the colors to terminal defaults.
Call this when you are done outputting colored text, or before program exit.
Definition at line 115 of file WithColor.cpp.
References colorsEnabled(), and llvm::raw_ostream::resetColor().
Referenced by ~WithColor().
|
static |
Convenience method for printing "warning: " to stderr.
Definition at line 63 of file WithColor.cpp.
References llvm::errs().
Referenced by llvm::DWARFContext::dumpWarning(), llvm::DWARFUnit::getCompilationDir(), llvm::DWARFVerifier::handleAccelTables(), llvm::SMDiagnostic::print(), llvm::PrintWarning(), and llvm::mca::verifyOperands().
|
static |
Convenience method for printing "warning: " to the given stream.
Definition at line 77 of file WithColor.cpp.
References llvm::StringRef::empty(), llvm::Warning, and WithColor().