| Issue |
58204
|
| Summary |
clang-format with C++20 likely/unlikely attributes breaks indentation
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
gohar94
|
When I run `clang-format` on the following code, it gives me weird indentation where it encounters `likely/unlikely`.
Input [`foo.cpp`]:
```c++
#include <iostream>
int foo(int a) {
if (a == 0) [[likely]] {
return 1;
}
if (a%2 == 0) {
std::cout << "Even" << std::endl;
return 1;
}
return 2;
}
```
Output:
```c++
#include <iostream>
int foo(int a) {
if (a == 0) [[likely]] {
return 1;
}
if (a % 2 == 0) {
std::cout << "Even" << std::endl;
return 1;
}
return 2;
}
```
Expected Output:
```c++
#include <iostream>
int foo(int a) {
if (a == 0) [[likely]] {
return 1;
}
if (a % 2 == 0) {
std::cout << "Even" << std::endl;
return 1;
}
return 2;
}
```
Command:
```
clang-format foo.cpp --fallback-style=Google
```
Notice how the `if` block with `likely` appears different than the second one (without any attributes).
Are there any particular options that can be passed to `clang-format` (or in a `.clang-format` file) to achieve the expected output?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs