aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/SourceMgr.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-06-08 09:46:34 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2020-06-08 09:48:47 -0700
commit550b5995233d6b087cddd65ff92507d7ed44f86e (patch)
treeea864eab1ae49bdd7d140cce7ba7937b2e333f4c /llvm/lib/Support/SourceMgr.cpp
parent67b700480b956855c66a228f4d3a3e428ab87742 (diff)
downloadllvm-550b5995233d6b087cddd65ff92507d7ed44f86e.zip
llvm-550b5995233d6b087cddd65ff92507d7ed44f86e.tar.gz
llvm-550b5995233d6b087cddd65ff92507d7ed44f86e.tar.bz2
[Support] Replace 'DisableColors' boolean with 'ColorMode' enum
Replace the DisableColors with a ColorMode which can be set to Auto, Enabled and Disabled. The purpose of this change is to make it possible to ignore the command line option not only for disabling colors, but also for enabling them. Differential revision: https://reviews.llvm.org/D81056
Diffstat (limited to 'llvm/lib/Support/SourceMgr.cpp')
-rw-r--r--llvm/lib/Support/SourceMgr.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp
index db5f7ad..9cc6973 100644
--- a/llvm/lib/Support/SourceMgr.cpp
+++ b/llvm/lib/Support/SourceMgr.cpp
@@ -450,8 +450,10 @@ static bool isNonASCII(char c) { return c & 0x80; }
void SMDiagnostic::print(const char *ProgName, raw_ostream &OS, bool ShowColors,
bool ShowKindLabel) const {
+ ColorMode Mode = ShowColors ? ColorMode::Auto : ColorMode::Disable;
+
{
- WithColor S(OS, raw_ostream::SAVEDCOLOR, true, false, !ShowColors);
+ WithColor S(OS, raw_ostream::SAVEDCOLOR, true, false, Mode);
if (ProgName && ProgName[0])
S << ProgName << ": ";
@@ -488,8 +490,7 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &OS, bool ShowColors,
}
}
- WithColor(OS, raw_ostream::SAVEDCOLOR, true, false, !ShowColors)
- << Message << '\n';
+ WithColor(OS, raw_ostream::SAVEDCOLOR, true, false, Mode) << Message << '\n';
if (LineNo == -1 || ColumnNo == -1)
return;
@@ -536,7 +537,8 @@ void SMDiagnostic::print(const char *ProgName, raw_ostream &OS, bool ShowColors,
printSourceLine(OS, LineContents);
{
- WithColor S(OS, raw_ostream::GREEN, true, false, !ShowColors);
+ ColorMode Mode = ShowColors ? ColorMode::Auto : ColorMode::Disable;
+ WithColor S(OS, raw_ostream::GREEN, true, false, Mode);
// Print out the caret line, matching tabs in the source line.
for (unsigned i = 0, e = CaretLine.size(), OutCol = 0; i != e; ++i) {