]> granicus.if.org Git - clang/commit
[clang-format] Look at NoLineBreak and NoLineBreakInOperand before breakProtrudingToken
authorKrasimir Georgiev <krasimir@google.com>
Wed, 8 Mar 2017 12:54:50 +0000 (12:54 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Wed, 8 Mar 2017 12:54:50 +0000 (12:54 +0000)
commit2e65e1ae92a3c54f32a60664cc71e6ce0efccf00
tree05beb474d576216b32f9a9f833aaf78b9b0105f8
parent8e67276e923bb759eb94f623c2529a6ca266e942
[clang-format] Look at NoLineBreak and NoLineBreakInOperand before breakProtrudingToken

Summary:
This patch makes ContinuationIndenter call breakProtrudingToken only if
NoLineBreak and NoLineBreakInOperand is false.

Previously, clang-format required two runs to converge on the following example with 24 columns:
Note that the second operand shouldn't be splitted according to NoLineBreakInOperand, but the
token breaker doesn't take that into account:
```
func(a, "long long long long", c);
```
After first run:
```
func(a, "long long "
        "long long",
         c);
```
After second run, where NoLineBreakInOperand is taken into account:
```
func(a,
     "long long "
     "long long",
     c);
```

With the patch, clang-format now obtains in one run:
```
func(a,
     "long long long"
     "long",
     c);
```
which is a better token split overall.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

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