xazax.hun abandoned this revision.
xazax.hun added a comment.
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
aaron.ballman added a comment.
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
hokein added inline comments.
Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:31
@@ +30,3 @@
+ unless(anyOf(hasOperatorName("=="), hasOperatorName("!="))),
+ hasEitherOperand(ignoringImpCasts(gnuNullExpr(
+ .bind("compareToNull"),
-
Eugene.Zelenko added inline comments.
Comment at: clang-tidy/misc/ComparisonMisuseCheck.cpp:21
@@ +20,3 @@
+void ComparisonMisuseCheck::registerMatchers(MatchFinder *Finder) {
+
+ Finder->addMatcher(
Please remove this line.
Repository:
rL LLVM
https://revie
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.
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 at: clang-tidy/misc/ComparisonM
falho created this revision.
falho added reviewers: xazax.hun, o.gyorgy, alexfh, aaron.ballman, etienneb,
hokein, Prazek.
falho added a subscriber: cfe-commits.
falho set the repository for this revision to rL LLVM.
This checker warns for the misuse of comparison operators
- char* is compared to