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
This commit is contained in:
Douglas Gregor 2009-05-03 15:24:25 +00:00
Родитель ee1ec39f54
Коммит 2167de4c49
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

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