[PATCH] D18703: [clang-tidy] Add new checker for comparison with runtime string functions.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 1 21:29:42 PDT 2016
alexfh added inline comments.
================
Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:38
@@ +37,3 @@
+ callExpr(hasDeclaration(functionDecl(
+ hasAnyName("__builtin_memcmp",
+ "__builtin_strcasecmp",
----------------
Should we add a configuration option to support custom string compare functions (e.g. lstrcmp)?
================
Comment at: docs/clang-tidy/checks/misc-suspicious-string-compare.rst:13
@@ +12,3 @@
+.. code:: c++
+ if (strcmp(...)) // Implicitly compare to zero
+ if (!strcmp(...)) // Won't warn
----------------
etienneb wrote:
> Any idea how to validate the look after formatting?
1. Install sphinx:
$ sudo apt-get install sphinx-common
2. Enable LLVM_BUILD_DOCS and maybe some other options in cmake.
3. ninja docs-clang-tools-html (or something similar, if you use make).
================
Comment at: test/clang-tidy/misc-suspicious-string-compare.cpp:119
@@ +118,3 @@
+ return 0;
+ // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wmemcmp' is called without explicitly comparing result [misc-suspicious-string-compare]
+ // CHECK-FIXES: wmemcmp(W, L"a", 1) != 0)
----------------
Please remove "[misc-suspicious-string-compare]" (and maybe some more static) from all but the first CHECK-MESSAGES lines.
http://reviews.llvm.org/D18703
More information about the cfe-commits
mailing list