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 | aef002292563d3c0690b1b60cb6a621fc01aaa1c (patch) | |
| tree | 49ba7bede340523ce2bf52dc02a4c1b370cb771d /clang/lib/Frontend | |
| parent | d69c3ee958f2e961bc7d98b69d8188ab3e1cf29f (diff) | |
| download | bcm5719-llvm-aef002292563d3c0690b1b60cb6a621fc01aaa1c.tar.gz bcm5719-llvm-aef002292563d3c0690b1b60cb6a621fc01aaa1c.zip | |
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>.
llvm-svn: 101426
Diffstat (limited to 'clang/lib/Frontend')
| -rw-r--r-- | clang/lib/Frontend/TextDiagnosticPrinter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Frontend/TextDiagnosticPrinter.cpp b/clang/lib/Frontend/TextDiagnosticPrinter.cpp index 6c8137e3d29..f2b16a4b386 100644 --- a/clang/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/clang/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(); |

