diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2013-12-26 23:38:39 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2013-12-26 23:38:39 +0000 |
| commit | 9d6712859adc067d38063ced47ed13d25e7b0ca7 (patch) | |
| tree | dc09fe15e593cd8b26bf5a7bd8ed9e5d5b11fd26 /lib/CodeGen/CGExprConstant.cpp | |
| parent | 667f331de32bf351e59b8d16ffb4333c3f27dcb5 (diff) | |
| download | clang-9d6712859adc067d38063ced47ed13d25e7b0ca7.tar.gz clang-9d6712859adc067d38063ced47ed13d25e7b0ca7.tar.bz2 clang-9d6712859adc067d38063ced47ed13d25e7b0ca7.tar.xz | |
Warn on mismatched parentheses in memcmp and friends.
Thisadds a new warning that warns on code like this:
if (memcmp(a, b, sizeof(a) != 0))
The warning looks like:
test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison]
if (memcmp(a, b, sizeof(a) != 0))
~~~~~~~~~~^~~~
test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead?
if (memcmp(a, b, sizeof(a) != 0))
^ ~
)
test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning
if (memcmp(a, b, sizeof(a) != 0))
^
(size_t)( )
1 warning generated.
This found 2 bugs in chromium and has 0 false positives on both chromium and
llvm.
The idea of triggering this warning on a binop in the size argument is due to
rnk.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
0 files changed, 0 insertions, 0 deletions
