]> granicus.if.org Git - clang/commit
[clang-format] Break non-trailing block comments
authorKrasimir Georgiev <krasimir@google.com>
Tue, 22 Aug 2017 14:40:05 +0000 (14:40 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Tue, 22 Aug 2017 14:40:05 +0000 (14:40 +0000)
commit6fb41bb4472969f7e2c25d6dd4f952d0748285e4
treef882c4dc39808831ede531f78df0386c08c4f23d
parent1b700ab92542a774697ab91eb85962715cede9a7
[clang-format] Break non-trailing block comments

Summary:
This patch is an alternative to https://reviews.llvm.org/D36614, by resolving a
non-idempotency issue by breaking non-trailing comments:

Consider formatting the following code with column limit at `V`:
```
                    V
const /* comment comment */ A = B;
```
The comment is not a trailing comment, breaking before it doesn't bring it under
the column limit. The formatter breaks after it, resulting in:

```
                    V
const /* comment comment */
    A = B;
```
For a next reformat, the formatter considers the comment as a trailing comment,
so it is free to break it further, resulting in:

```
                    V
const /* comment
         comment */
    A = B;
```
This patch improves the situation by directly producing the third case.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

Differential Revision: https://reviews.llvm.org/D37007

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311457 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTestComments.cpp