LLVM: lib/Support/WithColor.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
10
12
16
17using namespace llvm;
18
21 return ColorCategory;
22}
23namespace {
24struct CreateUseColor {
25 static void *call() {
28 cl::desc("Use colors in output (default=autodetect)"),
30 }
31};
32}
35
39}
40
43
46
48 switch (Color) {
51 break;
54 break;
57 break;
60 break;
63 break;
66 break;
69 break;
72 break;
75 break;
78 break;
79 }
80 }
81}
82
84
86
88
90
92 bool DisableColors) {
93 if (!Prefix.empty())
94 OS << Prefix << ": ";
98 << "error: ";
99}
100
102 bool DisableColors) {
103 if (!Prefix.empty())
104 OS << Prefix << ": ";
108 << "warning: ";
109}
110
112 bool DisableColors) {
113 if (!Prefix.empty())
114 OS << Prefix << ": ";
118 << "note: ";
119}
120
122 bool DisableColors) {
123 if (!Prefix.empty())
124 OS << Prefix << ": ";
128 << "remark: ";
129}
130
132 switch (Mode) {
134 return true;
136 return false;
138 return AutoDetectFunction(OS);
139 }
141}
142
144 bool BG) {
147 return *this;
148}
149
153 return *this;
154}
155
157
161 });
162}
163
167 });
168}
169
172}
173
176 AutoDetectFunction = NewAutoDetectFunction;
177}
Analysis containing CSE Info
static bool DefaultAutoDetectFunction(const raw_ostream &OS)
static ManagedStatic< cl::opt< cl::boolOrDefault >, CreateUseColor > UseColor
Base class for error info classes.
Lightweight error class with error context and mandatory checking.
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
StringRef - Represent a constant reference to a string, i.e.
An RAII object that temporarily switches an output stream to a specific color.
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.
static void defaultWarningHandler(Error Warning)
Implement default handling for Warning.
LLVM_CTOR_NODISCARD WithColor(raw_ostream &OS, HighlightColor S, ColorMode Mode=ColorMode::Auto)
To be used like this: WithColor(OS, HighlightColor::String) << "text";.
bool colorsEnabled()
Determine whether colors are displayed.
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
static raw_ostream & error()
Convenience method for printing "error: " to stderr.
bool(*)(const raw_ostream &OS) AutoDetectFunctionType
WithColor & resetColor()
Reset the colors to terminal defaults.
static void defaultErrorHandler(Error Err)
Implement default handling for Error.
static raw_ostream & note()
Convenience method for printing "note: " to stderr.
static AutoDetectFunctionType defaultAutoDetectFunction()
Retrieve the default color auto detection function.
static void setAutoDetectFunction(AutoDetectFunctionType NewAutoDetectFunction)
Change the global auto detection function.
static raw_ostream & remark()
Convenience method for printing "remark: " to stderr.
This class implements an extremely fast bulk output stream that can only output to a stream.
static constexpr Colors YELLOW
static constexpr Colors CYAN
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.
virtual raw_ostream & resetColor()
Resets the colors to terminal defaults.
static constexpr Colors BLUE
static constexpr Colors MAGENTA
static constexpr Colors BLACK
static constexpr Colors GREEN
virtual bool has_colors() const
This function determines if this stream is displayed and supports colors.
static constexpr Colors RED
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
void initWithColorOptions()
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
cl::OptionCategory & getColorCategory()
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
@ Auto
Determine whether to use color based on the command line argument and the raw_ostream.