[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy
Malcolm Parsons via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 26 14:24:18 PST 2016
malcolm.parsons added inline comments.
================
Comment at: clang-tidy/misc/StringCompareCheck.cpp:25
+ "operator instead";
+static const StringRef GuaranteeMessage = "'compare' is not guaranteed to "
+ "return -1 or 1; check for bigger or "
----------------
This message is not used.
================
Comment at: clang-tidy/misc/StringCompareCheck.cpp:37
+ hasArgument(0, expr().bind("str2")), argumentCountIs(1),
+ callee(memberExpr(has(implicitCastExpr(anyOf(
+ has(callExpr(has(implicitCastExpr(has(declRefExpr())))).bind("str1")),
----------------
Do you really care what the callee expression is?
Use `isArrow()` on the `MemberExpr` to check if it's a pointer.
================
Comment at: clang-tidy/misc/StringCompareCheck.cpp:67
+
+ if (const auto *zero = Result.Nodes.getNodeAs<Stmt>("zero")) {
+ const auto *str1 = Result.Nodes.getNodeAs<Stmt>("str1");
----------------
All variables should start with a capital letter.
https://reviews.llvm.org/D27210
More information about the cfe-commits
mailing list