]> granicus.if.org Git - clang/commit
[clang-format] Fix breaking of comment sections in unwrapped lines containing newlines.
authorKrasimir Georgiev <krasimir@google.com>
Thu, 2 Feb 2017 14:36:50 +0000 (14:36 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Thu, 2 Feb 2017 14:36:50 +0000 (14:36 +0000)
commit7c8a5bdbb0e994524cfcc25e2a8495155fd257c8
tree2cc8f31cd6597711a893f7ddc1d590d362382d2d
parentf65fd02738363bce0f094c4351788fd0bd5b73c1
[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
lib/Format/BreakableToken.cpp
lib/Format/FormatToken.h
lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTest.cpp