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.

llvm-svn: 70781
This commit is contained in:
Douglas Gregor 2009-05-03 15:24:25 +00:00
parent e49e9c3a52
commit cb5166211f
1 changed files with 3 additions and 2 deletions

View File

@ -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);