From 2cc2b9ca22d21cd855f06f545b8720f6a7a965b4 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 6 May 2009 04:43:47 +0000 Subject: [PATCH] Eliminate extra vertical space in Clang diagnostics git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71066 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../clang/Frontend/TextDiagnosticPrinter.h | 1 - lib/Frontend/TextDiagnosticPrinter.cpp | 24 +++---------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/include/clang/Frontend/TextDiagnosticPrinter.h b/include/clang/Frontend/TextDiagnosticPrinter.h index 8b3d0a916b..3c9dcb8d9c 100644 --- a/include/clang/Frontend/TextDiagnosticPrinter.h +++ b/include/clang/Frontend/TextDiagnosticPrinter.h @@ -74,7 +74,6 @@ public: SourceManager &SM, const CodeModificationHint *Hints, unsigned NumHints, - unsigned AvoidColumn, unsigned Columns); virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 90963c82ac..f936807b6c 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -243,7 +243,6 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, SourceManager &SM, const CodeModificationHint *Hints, unsigned NumHints, - unsigned AvoidColumn, unsigned Columns) { assert(!Loc.isInvalid() && "must have a valid source location here"); @@ -253,8 +252,7 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, if (!Loc.isFileID()) { SourceLocation OneLevelUp = SM.getImmediateInstantiationRange(Loc).first; // FIXME: Map ranges? - EmitCaretDiagnostic(OneLevelUp, Ranges, NumRanges, SM, 0, 0, AvoidColumn, - Columns); + EmitCaretDiagnostic(OneLevelUp, Ranges, NumRanges, SM, 0, 0, Columns); Loc = SM.getImmediateSpellingLoc(Loc); @@ -278,7 +276,7 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, } OS << "note: instantiated from:\n"; - EmitCaretDiagnostic(Loc, Ranges, NumRanges, SM, Hints, NumHints, 0,Columns); + EmitCaretDiagnostic(Loc, Ranges, NumRanges, SM, Hints, NumHints, Columns); return; } @@ -390,20 +388,6 @@ void TextDiagnosticPrinter::EmitCaretDiagnostic(SourceLocation Loc, SelectInterestingSourceRegion(SourceLine, CaretLine, FixItInsertionLine, CaretEndColNo, Columns); - // AvoidColumn tells us which column we should avoid when printing - // the source line. If the source line would start at or near that - // column, add another line of whitespace before printing the source - // line. Otherwise, the source line and the diagnostic text can get - // jumbled together. - unsigned StartCol = 0; - for (unsigned N = SourceLine.size(); StartCol != N; ++StartCol) - if (!isspace(SourceLine[StartCol])) - break; - - if (StartCol != SourceLine.size() && - abs((int)StartCol - (int)AvoidColumn) <= 2) - OS << '\n'; - // Finally, remove any blank spaces from the end of CaretLine. while (CaretLine[CaretLine.size()-1] == ' ') CaretLine.erase(CaretLine.end()-1); @@ -673,13 +657,12 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, OutStr += ']'; } - bool WordWrapped = false; if (MessageLength) { // We will be word-wrapping the error message, so compute the // column number where we currently are (after printing the // location information). unsigned Column = OS.tell() - StartOfLocationInfo; - WordWrapped = PrintWordWrapped(OS, OutStr, MessageLength, Column); + PrintWordWrapped(OS, OutStr, MessageLength, Column); } else { OS.write(OutStr.begin(), OutStr.size()); } @@ -718,7 +701,6 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, EmitCaretDiagnostic(LastLoc, Ranges, NumRanges, LastLoc.getManager(), Info.getCodeModificationHints(), Info.getNumCodeModificationHints(), - WordWrapped? WordWrapIndentation : 0, MessageLength); } -- 2.40.0