diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-16 00:23:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-16 00:23:51 +0000 |
commit | ce487ef6c1ba3b35250ce5bfe053e24e34a854e6 (patch) | |
tree | 5b3e31d06a6cf3e54abd54a72c2182f5095a7fcd /lib/Frontend/TextDiagnosticPrinter.cpp | |
parent | c0b39640de335809ca7544f802751112619f30cc (diff) |
Fix a bug in caret-line-pruning logic that only happens when we have a
source line wider than the terminal where the associated fix-it line
is longer than the caret line. Previously, we would crash in this
case, which was rather unfortunate. Fixes <rdar://problem/7856226>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101426 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 6c8137e3d2..f2b16a4b38 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -148,9 +148,16 @@ static void SelectInterestingSourceRegion(std::string &SourceLine, std::string &FixItInsertionLine, unsigned EndOfCaretToken, unsigned Columns) { - if (CaretLine.size() > SourceLine.size()) - SourceLine.resize(CaretLine.size(), ' '); - + unsigned MaxSize = std::max(SourceLine.size(), + std::max(CaretLine.size(), + FixItInsertionLine.size())); + if (MaxSize > SourceLine.size()) + SourceLine.resize(MaxSize, ' '); + if (MaxSize > CaretLine.size()) + CaretLine.resize(MaxSize, ' '); + if (!FixItInsertionLine.empty() && MaxSize > FixItInsertionLine.size()) + FixItInsertionLine.resize(MaxSize, ' '); + // Find the slice that we need to display the full caret line // correctly. unsigned CaretStart = 0, CaretEnd = CaretLine.size(); |