clang-tidy: Add check readability-implicit-bool-conversion
Check readability-implicit-bool-conversion
Add and apply clang-tidy check readability-implicit-bool-conversion.
This check detects implicit bool conversions from / to integers. This implicit conversion is pretty standard in C/C++, but it can hide underlying bugs if used incorrectly. The following MRs fix non-trivial issues detected by this check, which were not caught by compilers.
!1194 (merged), !1200 (merged), !1201 (merged), !1202 (merged), !1203 (merged), !1204 (merged), !1205 (merged), !1213 (merged), !1215 (merged)
This check may not be consensual, since it can make the code less readable, although more type safe.
Other fixes
Additionally, this MR proposes more fixes to the implicit bool conversion by changing the API of the functions. In theory, these changes should not break existing code, since int
can be implicitly converted to bool
. Nevertheless, I separated them in a separate commit, in case we need to explicitly state those changes in the RELEASE_NOTES or mark them as deprecated before removing.