[PATCH] D18703: [clang-tidy] Add new checker for comparison with runtime string functions.

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 08:37:39 PDT 2016


alexfh added inline comments.

================
Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:73
@@ +72,3 @@
+      functionDecl(
+          hasAnyName("__builtin_memcmp",
+                     "__builtin_strcasecmp",
----------------
I'd  initialize the list as a comma/semicolon-separated list in a single string.

================
Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:119
@@ +118,3 @@
+  // Add the list of user-defined string compare-like functions.
+  for (const auto &FunctionName : StringCompareLikeFunctions) {
+    IsStringCompareFunction =
----------------
The loop is not needed. I guess, you just can use the proper hasAnyName overload.

================
Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:218
@@ +217,3 @@
+         "function '%0' is compared using logical not operator")
+        << Decl->getName()
+        << FixItHint::CreateRemoval(
----------------
getName() is not needed.

================
Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:230
@@ +229,3 @@
+
+  if (Result.Nodes.getNodeAs<Stmt>("invalid-conversion") != nullptr) {
+    diag(Call->getLocStart(),
----------------
` != nullptr` is not commonly used in clang/clang-tidy code.


http://reviews.llvm.org/D18703





More information about the cfe-commits mailing list