diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-01-31 13:32:38 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-01-31 13:32:38 +0000 |
commit | 753625b62e2bd6ce5873ce15972b3c3fba8ff6c0 (patch) | |
tree | 6a43eddb7b6b0aa355976891209a606e4a544d33 /clang/lib/Format/BreakableToken.cpp | |
parent | 6f033f0c30bd0b82ace89a7ef5fb7be3fc52c0b3 (diff) | |
download | bcm5719-llvm-753625b62e2bd6ce5873ce15972b3c3fba8ff6c0.tar.gz bcm5719-llvm-753625b62e2bd6ce5873ce15972b3c3fba8ff6c0.zip |
[clang-format] Fix regression merging comments across newlines.
Summary:
This fixes a regression that causes example:
```
enum A {
a, // line a
// line b
b
};
```
to be formatted as follows:
```
enum A {
a, // line a
// line b
b
};
```
Reviewers: djasper, klimek
Reviewed By: klimek
Subscribers: cfe-commits, sammccall, djasper, klimek
Differential Revision: https://reviews.llvm.org/D29322
llvm-svn: 293624
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index dd28ba7d4a2..82e62ac80f8 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -681,6 +681,23 @@ BreakableLineCommentSection::BreakableLineCommentSection( Content[i] = Content[i].substr(0, EndOfLine); } LineTok = CurrentTok->Next; + if (CurrentTok->Next && CurrentTok->Next->NewlinesBefore > 1) { + // 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 + // would split the contents of the enum into two unwrapped lines in this + // example, which is undesirable: + // enum A { + // a, // comment about a + // + // // comment about b + // b + // }; + // + // FIXME: Consider putting separate line comment sections as children to + // the unwrapped line instead. + break; + } } } |