]> granicus.if.org Git - clang/commit
[Sema] Add a new warning, -Wmemset-transposed-args
authorErik Pilkington <erik.pilkington@gmail.com>
Thu, 19 Jul 2018 16:46:15 +0000 (16:46 +0000)
committerErik Pilkington <erik.pilkington@gmail.com>
Thu, 19 Jul 2018 16:46:15 +0000 (16:46 +0000)
commitbc7f4ca3e4f17a52e031b96b66604b5a26298012
tree549c0e8a456004f20ba5fd070105be1d66df15b6
parent4da33cdc63891fc48d632437e315279d271b71b4
[Sema] Add a new warning, -Wmemset-transposed-args

This diagnoses calls to memset that have the second and third arguments
transposed, for example:

  memset(buf, sizeof(buf), 0);

This is done by checking if the third argument is a literal 0, or if the second
is a sizeof expression (and the third isn't). The first check is also done for
calls to bzero.

Differential revision: https://reviews.llvm.org/D49112

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@337470 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaChecking.cpp
test/Sema/transpose-memset.c [new file with mode: 0644]