[PATCH] D32700: [clang-tidy] Add misc-suspicious-memset-usage check.
Reka Kovacs via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 1 06:06:02 PDT 2017
rnkovacs created this revision.
Herald added a subscriber: mgorny.
This check finds memset calls with potential mistakes in their arguments.
Cases covered:
- Fill value is a character '0'. Integer 0 might have been intended.
- Fill value is out of character range and gets truncated.
- The destination is a this pointer within a class that has a virtual function. It might reset the virtual pointer.
The existing google-runtime-memset-zero-length check is related. It finds cases when the byte count parameter is zero and offers to swap that with the fill value argument. Perhaps the two could be merged while maintaining backward compatibility through an alias. When turned on using the alias name, the check would only examine the count parameter as in the google check.
Any suggestions are appreciated.
https://reviews.llvm.org/D32700
Files:
clang-tidy/misc/CMakeLists.txt
clang-tidy/misc/MiscTidyModule.cpp
clang-tidy/misc/SuspiciousMemsetUsageCheck.cpp
clang-tidy/misc/SuspiciousMemsetUsageCheck.h
docs/clang-tidy/checks/list.rst
docs/clang-tidy/checks/misc-suspicious-memset-usage.rst
test/clang-tidy/misc-suspicious-memset-usage.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32700.97279.patch
Type: text/x-patch
Size: 12354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170501/8e9c1e44/attachment-0001.bin>
More information about the cfe-commits
mailing list