From: Alp Toker Date: Sat, 21 Jun 2014 23:31:52 +0000 (+0000) Subject: TextDiagnostic: print remark level diagnostics in bold too X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=339f28387aa3c334a3290561c89fba6bbe458494;p=clang TextDiagnostic: print remark level diagnostics in bold too The purpose of bolding these is to make them visually distinct from continuations (supplemental note diagnostics). Therefore, the bolding applies to all severities _including_ remarks -- it's not in any way an indicator of priority. Also simplify and comment. No tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211447 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/TextDiagnostic.h b/include/clang/Frontend/TextDiagnostic.h index 2aa95760fd..a76c2bb984 100644 --- a/include/clang/Frontend/TextDiagnostic.h +++ b/include/clang/Frontend/TextDiagnostic.h @@ -63,18 +63,16 @@ public: /// formatting of their diagnostic messages. /// /// \param OS Where the message is printed - /// \param Level Used to colorizing the message + /// \param IsSupplemental true if this is a continuation note diagnostic /// \param Message The text actually printed /// \param CurrentColumn The starting column of the first line, accounting /// for any prefix. /// \param Columns The number of columns to use in line-wrapping, 0 disables /// all line-wrapping. /// \param ShowColors Enable colorizing of the message. - static void printDiagnosticMessage(raw_ostream &OS, - DiagnosticsEngine::Level Level, - StringRef Message, - unsigned CurrentColumn, unsigned Columns, - bool ShowColors); + static void printDiagnosticMessage(raw_ostream &OS, bool IsSupplemental, + StringRef Message, unsigned CurrentColumn, + unsigned Columns, bool ShowColors); protected: void emitDiagnosticMessage(SourceLocation Loc,PresumedLoc PLoc, diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index 7d39c74cea..840c280b51 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -689,8 +689,9 @@ TextDiagnostic::emitDiagnosticMessage(SourceLocation Loc, printDiagnosticLevel(OS, Level, DiagOpts->ShowColors, DiagOpts->CLFallbackMode); - printDiagnosticMessage(OS, Level, Message, - OS.tell() - StartOfLocationInfo, + printDiagnosticMessage(OS, + /*IsSupplemental*/ Level == DiagnosticsEngine::Note, + Message, OS.tell() - StartOfLocationInfo, DiagOpts->MessageLength, DiagOpts->ShowColors); } @@ -735,24 +736,18 @@ TextDiagnostic::printDiagnosticLevel(raw_ostream &OS, OS.resetColor(); } -/*static*/ void -TextDiagnostic::printDiagnosticMessage(raw_ostream &OS, - DiagnosticsEngine::Level Level, - StringRef Message, - unsigned CurrentColumn, unsigned Columns, - bool ShowColors) { +/*static*/ +void TextDiagnostic::printDiagnosticMessage(raw_ostream &OS, + bool IsSupplemental, + StringRef Message, + unsigned CurrentColumn, + unsigned Columns, bool ShowColors) { bool Bold = false; - if (ShowColors) { - // Print warnings, errors and fatal errors in bold, no color - switch (Level) { - case DiagnosticsEngine::Warning: - case DiagnosticsEngine::Error: - case DiagnosticsEngine::Fatal: - OS.changeColor(savedColor, true); - Bold = true; - break; - default: break; //don't bold notes - } + if (ShowColors && !IsSupplemental) { + // Print primary diagnostic messages in bold and without color, to visually + // indicate the transition from continuation notes and other output. + OS.changeColor(savedColor, true); + Bold = true; } if (Columns)