]> granicus.if.org Git - clang/commit
[analyzer] MallocSizeofChecker false positive: when sizeof is argument
authorAnna Zaks <ganna@apple.com>
Fri, 8 Jun 2012 18:44:43 +0000 (18:44 +0000)
committerAnna Zaks <ganna@apple.com>
Fri, 8 Jun 2012 18:44:43 +0000 (18:44 +0000)
commit2e336ac5ace420470bbb0ff54a94a5484443a44f
tree9d2c96652685dde14cad60133aef390a4a0112b7
parent6fe6a49c4058211ff4489023c78615ec0266c5ff
[analyzer] MallocSizeofChecker false positive: when sizeof is argument
to addition.

We should not to warn in case the malloc size argument is an
addition containing 'sizeof' operator - it is common to use the pattern
to pack values of different sizes into a buffer.

Ex:

uint8_t *buffer = (uint8_t*)malloc(dataSize + sizeof(length));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158219 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/MallocSizeofChecker.cpp
test/Analysis/malloc-sizeof.c