diff options
author | Marek Kurdej <marek.kurdej+llvm.org@gmail.com> | 2022-01-14 21:42:09 +0100 |
---|---|---|
committer | Marek Kurdej <marek.kurdej+llvm.org@gmail.com> | 2022-01-14 21:47:16 +0100 |
commit | 6ea3d9efc53641d930e9176916ff09ca6f73aef2 (patch) | |
tree | 53620c27fb5dd3aba00dc79118062f5040fc74b4 /clang/unittests/Format/FormatTestJava.cpp | |
parent | 0ab54c28f8b5b2436561f496636b184786b79389 (diff) | |
download | llvm-6ea3d9efc53641d930e9176916ff09ca6f73aef2.zip llvm-6ea3d9efc53641d930e9176916ff09ca6f73aef2.tar.gz llvm-6ea3d9efc53641d930e9176916ff09ca6f73aef2.tar.bz2 |
[clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine/BraceWrapping.BeforeLambdaBody are set
In clang-format 12, `CompactNamespaces` misformatted the code when `AllowShortLambdasOnASingleLine` is set to false and `BraceWrapping.BeforeLambdaBody` is true.
Input:
```
namespace out {
namespace in {
}
} // namespace out::in
```
Expected output:
```
namespace out { namespace in {
}} // namespace out::in
```
Output from v12:
```
namespace out {
namespace in {
}
} // namespace out::in
```
Config triggering the issue:
```
---
AllowShortLambdasOnASingleLine: None
BraceWrapping:
BeforeLambdaBody : true
BreakBeforeBraces: Custom
CompactNamespaces: true
...
```
Seems there's a corner case when `AllowShortLambdasOnASingleLine` is false, and `BraceWrapping.BeforeLambdaBody` is true, that causes CompactNamespaces to stop working.
The cause was a misannotation of `{` opening brace after `namespace` as a lambda opening brace.
The regression was probably introduced with [this commit](https://github.com/llvm/llvm-project/commit/fa0118e6e588fe303b08e7e06ba28ac1f8d50c68).
Originally contributed by Ahmed Mahdy (@aybassiouny). Thank you!
Reviewed By: Wawha, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D99031
Diffstat (limited to 'clang/unittests/Format/FormatTestJava.cpp')
0 files changed, 0 insertions, 0 deletions