Index: llvm/lib/Support/raw_ostream.cpp =================================================================== --- llvm/lib/Support/raw_ostream.cpp +++ llvm/lib/Support/raw_ostream.cpp @@ -326,7 +326,7 @@ } raw_ostream &raw_ostream::operator<<(const FormattedString &FS) { - unsigned Len = FS.Str.size(); + unsigned Len = FS.Str.size(); int PadAmount = FS.Width - Len; if (FS.RightJustify && (PadAmount > 0)) this->indent(PadAmount); @@ -640,6 +640,8 @@ raw_ostream &raw_fd_ostream::changeColor(enum Colors colors, bool bold, bool bg) { + if (!has_colors()) + return *this; if (sys::Process::ColorNeedsFlush()) flush(); const char *colorcode = @@ -655,6 +657,8 @@ } raw_ostream &raw_fd_ostream::resetColor() { + if (!has_colors()) + return *this; if (sys::Process::ColorNeedsFlush()) flush(); const char *colorcode = sys::Process::ResetColor(); @@ -668,6 +672,8 @@ } raw_ostream &raw_fd_ostream::reverseColor() { + if (!has_colors()) + return *this; if (sys::Process::ColorNeedsFlush()) flush(); const char *colorcode = sys::Process::OutputReverse();