This checker warns for the misuse of comparison operators
- char* is compared to a string literal
- inequality operator usage for NULL
Differential D23427
[Clang-tidy] Comparison Misuse xazax.hun on Aug 11 2016, 2:11 PM. Authored by
Details
This checker warns for the misuse of comparison operators
Diff Detail
Event TimelineComment Actions Please mention this check in docs/ReleaseNotes.rst (in alphabetical order). Please run Clang-format on newly added files. Test case is definitely needs it.
Comment Actions Thank you for working on this check! We already have a frontend diagnostic for comparisons between string literals and pointers, so I'm not certain of the utility of adding a clang-tidy check for that case (see -Wstring-compare, aka, http://coliru.stacked-crooked.com/a/6f6ca7fd2f6db09a). Comparisons against nullptr seems like it could also be handled as a frontend check as well, perhaps.
Comment Actions For the first case ToT clang compiler gives a warning (-Wstring-compare), for the second case, it generates a compiler error (error: ordered comparison between pointer and zero). Note that, older versions of clang did not even give a warning for that case. It looks like this check no longer makes sense considering the current warnings and errors of clang top of tree. |
Check, please.