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 | b6ccd38deecfcdb62280491553ad558efe5db6ec (patch) | |
tree | a6033a370a4e6ca79d5d8ac645d4a646f37ac845 /clang/lib/Format/BreakableToken.cpp | |
parent | 98075fe1815252ad52dbeded432f37908f294057 (diff) | |
download | bcm5719-llvm-b6ccd38deecfcdb62280491553ad558efe5db6ec.tar.gz bcm5719-llvm-b6ccd38deecfcdb62280491553ad558efe5db6ec.zip |
[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
llvm-svn: 293891
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 09f17a35d07..e9dd253f3ec 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/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 |