clang-format formats {#if}/{if...else}/{#endif}/{if}/{statement} sequence wrong
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
I got this from `clang-format --style=LLVM -i a.c`:
```c
void a() {
#if __linux__
if (addr.sun_path[0] == '@') // linux abstract socket
addr.sun_path[0] = '\0';
else
#endif
if (stat(unix, &sb) && S_ISSOCK(sb.st_mode))
unlink(unix);
}
```
the correct formatting would be
```c
void a() {
#if __linux__
if (addr.sun_path[0] == '@') // linux abstract socket
addr.sun_path[0] = '\0';
else
#endif
if (stat(unix, &sb) && S_ISSOCK(sb.st_mode))
unlink(unix);
}
```
or maybe
```c
void a() {
#if __linux__
if (addr.sun_path[0] == '@') // linux abstract socket
addr.sun_path[0] = '\0';
else
#endif
if (stat(unix, &sb) && S_ISSOCK(sb.st_mode))
unlink(unix);
}
```
but definitely not the first one.
Debian clang-format version 21.0.0 (++20250519112653+d0ee35851bb9-1~exp1~20250519112844.1459)
Contributor guide
Assessment
This issue has not been assessed yet.