summaryrefslogtreecommitdiffstats
path: root/clang/lib
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
commitcb5166211f4152c378dbce19b76cfacca64f02dc (patch)
tree9dd680da558872ed41949e943227e883179af7ec /clang/lib
parente49e9c3a524e0ab428673d6d7589cf81d69017da (diff)
downloadbcm5719-llvm-cb5166211f4152c378dbce19b76cfacca64f02dc.tar.gz
bcm5719-llvm-cb5166211f4152c378dbce19b76cfacca64f02dc.zip
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
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Frontend/TextDiagnosticPrinter.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp
index 042e894febc..62446f33007 100644
--- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud