diff options
| author | Alexander Kornienko <alexfh@google.com> | 2015-01-12 13:11:12 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2015-01-12 13:11:12 +0000 |
| commit | 00691cf3bb816f04c0ebed36c7d6428ad2fe0fb1 (patch) | |
| tree | fcb723d4113331a9c7070d3aec19449156dfa078 /clang/lib/Format | |
| parent | 9761e96b011f0ef7ca380a25c96d3c04fed84b2d (diff) | |
| download | bcm5719-llvm-00691cf3bb816f04c0ebed36c7d6428ad2fe0fb1.tar.gz bcm5719-llvm-00691cf3bb816f04c0ebed36c7d6428ad2fe0fb1.zip | |
Fix assertion in BreakableBlockComment (http://llvm.org/PR21916).
Reviewers: djasper
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D6894
llvm-svn: 225628
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Format/BreakableToken.h | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 1bea0e56513..26f1371b409 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -303,7 +303,8 @@ BreakableBlockComment::BreakableBlockComment( StartOfLineColumn[i] += Decoration.size(); Lines[i] = Lines[i].substr(Decoration.size()); LeadingWhitespace[i] += Decoration.size(); - IndentAtLineBreak = std::min<int>(IndentAtLineBreak, StartOfLineColumn[i]); + IndentAtLineBreak = + std::min<int>(IndentAtLineBreak, std::max(0, StartOfLineColumn[i])); } IndentAtLineBreak = std::max<unsigned>(IndentAtLineBreak, Decoration.size()); DEBUG({ diff --git a/clang/lib/Format/BreakableToken.h b/clang/lib/Format/BreakableToken.h index 6f49ed2d367..eb1f9fda307 100644 --- a/clang/lib/Format/BreakableToken.h +++ b/clang/lib/Format/BreakableToken.h @@ -212,6 +212,11 @@ private: // StartOfLineColumn[i] is the target column at which Line[i] should be. // Note that this excludes a leading "* " or "*" in case all lines have // a "*" prefix. + // The first line's target column is always positive. The remaining lines' + // target columns are relative to the first line to allow correct indentation + // of comments in \c WhitespaceManager. Thus they can be negative as well (in + // case the first line needs to be unindented more than there's actual + // whitespace in another line). SmallVector<int, 16> StartOfLineColumn; // The column at which the text of a broken line should start. |

