diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-02-02 14:36:50 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-02-02 14:36:50 +0000 |
commit | 7c8a5bdbb0e994524cfcc25e2a8495155fd257c8 (patch) | |
tree | 2cc8f31cd6597711a893f7ddc1d590d362382d2d /lib/Format/BreakableToken.cpp | |
parent | f65fd02738363bce0f094c4351788fd0bd5b73c1 (diff) |
[clang-format] Fix breaking of comment sections in unwrapped lines containing newlines.
Summary:
The breaking of line comment sections was misaligning the case where the first comment line is on an unwrapped line containing newlines. In this case, the breaking column must be based on the source column of the last token that is preceded by a newline, not on the first token of the unwrapped line.
source:
```
enum A {
a, // line 1
// line 2
};
```
format before:
```
enum A {
a, // line 1
// line 2
};
```
format after:
```
enum A {
a, // line 1
// line 2
};
```
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D29444
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293891 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/BreakableToken.cpp')
-rw-r--r-- | lib/Format/BreakableToken.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index 09f17a35d0..e9dd253f3e 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -695,7 +695,7 @@ BreakableLineCommentSection::BreakableLineCommentSection( Content[i] = Content[i].substr(0, EndOfLine); } LineTok = CurrentTok->Next; - if (CurrentTok->Next && CurrentTok->Next->NewlinesBefore > 1) { + if (CurrentTok->Next && !CurrentTok->Next->ContinuesLineCommentSection) { // A line comment section needs to broken by a line comment that is // preceded by at least two newlines. Note that we put this break here // instead of breaking at a previous stage during parsing, since that |