Hi all,
I have seen (and written myself) code like:
bool foo() {
if (something)
return 0; // implicit conversion of int literal to bool
}
This conversion is benign, however it often impairs readability. There is a clang-tidy's check that finds/transforms the integral literals to bool ones - modernize-use-of-bool-literals. Here I'm proposing to apply the check across chromium (and other repos) to fix such uses.
Possible controversial topics:
- while (1) { ... }. This is quite common and actually idiomatic in C89, where there is no the bool type. According to codesearch, we have more "while (1)" than "while (true)" (5600 vs 3814). I propose to not touch these cases and fix/augment the clang-tidy's check in upstream.
- some unittest data (here, for example), where the use of integral literals is more representative. There seem to be not many cases like this, so I'd also propose to not rewrite them.
What do you think?