| Issue |
164770
|
| Summary |
[clang-tidy] Check request: readability-avoid-yoda-conditions
|
| Labels |
clang-tidy,
check-request
|
| Assignees |
|
| Reporter |
carlosgalvezp
|
It would be good to have a check that converts [yoda conditions](https://en.wikipedia.org/wiki/Yoda_conditions) into normal conditions, as read into plain English from left to right.
Example:
```cpp
if (0 == foo())
{}
```
should be converted into:
```cpp
if (foo() == 0)
{}
```
In 2025, accidental assignments should no longer be a thing, tools have caught up. Compilers warn about it via `-Wparentheses`, active by default in Clang and via `-Wall` in GCC.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs