aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/TextDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-05-03 15:24:25 +0000
committerDouglas Gregor <dgregor@apple.com>2009-05-03 15:24:25 +0000
commit2167de4c4934d6beb3af3a4d74ee160def67f74a (patch)
tree3216bc9691d68637605876c68b1f168649c9fca0 /lib/Frontend/TextDiagnosticPrinter.cpp
parentee1ec39f54a759a1c0858b608e02d70e0d7f54bc (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r--lib/Frontend/TextDiagnosticPrinter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 042e894feb..62446f3300 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -158,7 +158,7 @@ static void SelectInterestingSourceRegion(std::string &SourceLine,
// 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 @@ static void SelectInterestingSourceRegion(std::string &SourceLine,
// 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);