[cfe-commits] r70781 - /cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Douglas Gregor
dgregor at apple.com
Sun May 3 08:24:26 PDT 2009
Author: dgregor
Date: Sun May 3 10:24:25 2009
New Revision: 70781
URL: http://llvm.org/viewvc/llvm-project?rev=70781&view=rev
Log:
Fix crash in source-line truncation code for diagnostic
printing. Also, when we only need to truncate the line at the end,
make sure there is room for the ellipsis.
Modified:
cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
Modified: cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp?rev=70781&r1=70780&r2=70781&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/TextDiagnosticPrinter.cpp Sun May 3 10:24:25 2009
@@ -158,7 +158,7 @@
// If the end of the interesting region comes before we run out of
// space in the terminal, start at the beginning of the line.
- if (CaretEnd < Columns)
+ if (CaretEnd < Columns - 3)
CaretStart = 0;
unsigned TargetColumns = Columns - 8; // Give us extra room for the ellipses.
@@ -251,7 +251,8 @@
// before the lines so that it looks nicer.
if (CaretEnd < SourceLine.size())
SourceLine.replace(CaretEnd, std::string::npos, "...");
- //CaretLine.erase(CaretEnd, std::string::npos);
+ if (CaretEnd < CaretLine.size())
+ CaretLine.erase(CaretEnd, std::string::npos);
if (FixItInsertionLine.size() > CaretEnd)
FixItInsertionLine.erase(CaretEnd, std::string::npos);
More information about the cfe-commits
mailing list