clang-format mishandles logical-and-expression statement
Open
clang-format
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```cpp
int a;
int b;
int main(){
a && b;
if (a && b);
}
```
With `-style=LLVM` it outputs:
```cpp
int a;
int b;
int main() {
a &&b;
if (a && b)
;
}
```
`a &&b;` looks bad.
Godbolt link of example: https://godbolt.org/z/cx7PWbK6h
Contributor guide
Research direction
Start by running clang-format with -style=LLVM on the C++ snippet from the issue and compare the spacing around the logical-and expression. Trace the clang-format handling for expression statements, then add or update coverage for the shown output so the spacing before b is correct while the existing if-statement formatting remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100