1717#include " llvm/Support/ConvertUTF.h"
1818#include " llvm/Support/ErrorHandling.h"
1919#include " llvm/Support/Locale.h"
20- #include " llvm/Support/raw_ostream.h"
2120#include < algorithm>
2221#include < optional>
2322
@@ -662,7 +661,7 @@ void TextDiagnostic::emitDiagnosticMessage(
662661 FullSourceLoc Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level,
663662 StringRef Message, ArrayRef<clang::CharSourceRange> Ranges,
664663 DiagOrStoredDiag D) {
665- uint64_t StartOfLocationInfo = OS.tell ();
664+ uint64_t StartOfLocationInfo = OS.getColumn ();
666665
667666 // Emit the location of this particular diagnostic.
668667 if (Loc.isValid ())
@@ -675,7 +674,7 @@ void TextDiagnostic::emitDiagnosticMessage(
675674 printDiagnosticLevel (OS, Level, DiagOpts.ShowColors );
676675 printDiagnosticMessage (OS,
677676 /* IsSupplemental*/ Level == DiagnosticsEngine::Note,
678- Message, OS.tell () - StartOfLocationInfo,
677+ Message, OS.getColumn () - StartOfLocationInfo,
679678 DiagOpts.MessageLength , DiagOpts.ShowColors );
680679}
681680
@@ -688,11 +687,21 @@ TextDiagnostic::printDiagnosticLevel(raw_ostream &OS,
688687 switch (Level) {
689688 case DiagnosticsEngine::Ignored:
690689 llvm_unreachable (" Invalid diagnostic type" );
691- case DiagnosticsEngine::Note: OS.changeColor (noteColor, true ); break ;
692- case DiagnosticsEngine::Remark: OS.changeColor (remarkColor, true ); break ;
693- case DiagnosticsEngine::Warning: OS.changeColor (warningColor, true ); break ;
694- case DiagnosticsEngine::Error: OS.changeColor (errorColor, true ); break ;
695- case DiagnosticsEngine::Fatal: OS.changeColor (fatalColor, true ); break ;
690+ case DiagnosticsEngine::Note:
691+ OS.changeColor (noteColor, true );
692+ break ;
693+ case DiagnosticsEngine::Remark:
694+ OS.changeColor (remarkColor, true );
695+ break ;
696+ case DiagnosticsEngine::Warning:
697+ OS.changeColor (warningColor, true );
698+ break ;
699+ case DiagnosticsEngine::Error:
700+ OS.changeColor (errorColor, true );
701+ break ;
702+ case DiagnosticsEngine::Fatal:
703+ OS.changeColor (fatalColor, true );
704+ break ;
696705 }
697706 }
698707
@@ -1459,7 +1468,7 @@ void TextDiagnostic::emitSnippet(StringRef SourceLine,
14591468
14601469 // Print the source line one character at a time.
14611470 bool PrintReversed = false ;
1462- std::optional<llvm:: raw_ostream::Colors> CurrentColor;
1471+ std::optional<raw_ostream::Colors> CurrentColor;
14631472 size_t I = 0 ;
14641473 while (I < SourceLine.size ()) {
14651474 auto [Str, WasPrintable] =
@@ -1485,7 +1494,7 @@ void TextDiagnostic::emitSnippet(StringRef SourceLine,
14851494 if (CharStyle != Styles.end ()) {
14861495 if (!CurrentColor ||
14871496 (CurrentColor && *CurrentColor != CharStyle->Color )) {
1488- OS.changeColor (CharStyle->Color , false );
1497+ OS.changeColor (CharStyle->Color );
14891498 CurrentColor = CharStyle->Color ;
14901499 }
14911500 } else if (CurrentColor) {
0 commit comments