Skip to content

[clang-tidy] Check request: readability-avoid-yoda-conditions #164770

@carlosgalvezp

Description

@carlosgalvezp

It would be good to have a check that converts yoda conditions into normal conditions, as read into plain English from left to right.

Example:

if (0 == foo())
{}

should be converted into:

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.

Metadata

Metadata

Labels

check-requestRequest for a new check in clang-tidyclang-tidyduplicateResolved as duplicategood first issuehttps://github.com/llvm/llvm-project/contribute

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions