| Issue |
52911
|
| Summary |
Nested scopes regression in clang-format 13.0.0, worked in clang-format 12.0.1
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
JohnC32
|
Nested scopes do not work in 13.0.0. Below we use scopes to increase indentation to group like items, a common pattern in writing checks. Here I've simplified things a bit.
Using clang-format 12.0.1, on testcheck.cpp we have:
```c++
int foo() {
// first check
{
int a = 1;
CHECK(a == 1);
}
// extra scope to group common types of checks
{
{
char a = 'a';
CHECK(a == 'a');
}
{
char b = 'b';
CHECK(b == 'b');
}
}
// other checks
{
bool b = false;
CHECK(b == false);
}
}
```
If I then run clang-format 13.0.0 on testcheck.cpp we get:
```c++
// clang-format 13.0.0 result
int foo() {
// first check
{
int a = 1;
CHECK(a == 1);
}
// extra scope to group common types of checks
{{char a = 'a';
CHECK(a == 'a');
}
{
char b = 'b';
CHECK(b == 'b');
}
}
// other checks
{
bool b = false;
CHECK(b == false);
}
}
```
Here's the _clang-format used in the above.
```yaml
---
BasedOnStyle: Google
IndentWidth: 4
...
```
This maybe related to issue #42582, but for my case all is good with clang-format 12.0.1 and we have issues with 13.0.0. Since this is a regression, I'm though it may help to create a separate issue.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs