[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 13 07:24:40 PST 2016

alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.

Comment at: clang-tidy/misc/StringCompareCheck.cpp:48
+    diag(Matched->getLocStart(),
+         "do not use compare to test equality of strings; "
+         "use the string equality operator instead");
`compare` should be enclosed in single quotes (`'compare'`), since it refers to a method.

Comment at: docs/clang-tidy/checks/misc-string-compare.rst:12
+zero depending on the lexicographical relationship between the strings compared. 
+If an equality or inequality check can suffice, that is recommended.
The documentation doesn't explain why is using `compare` for equality comparison should be avoided. Maybe `that is recommended to avoid the risk of incorrect interpretation of the return value and simplify the code`?


More information about the cfe-commits mailing list