OSDN Git Service

Don't consider allocsize functions to be allocation functions.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Fri, 23 Dec 2016 01:18:09 +0000 (01:18 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Fri, 23 Dec 2016 01:18:09 +0000 (01:18 +0000)
commitd4a4c083501be247c1e3d388ebd6f22e7a610902
treef1e1ea677106ad4641fd8472dbf20f5e8b892b52
parentadf4cb67d7f1134ea69c60461192afc2664c6005
Don't consider allocsize functions to be allocation functions.

This patch fixes some ASAN unittest failures on FreeBSD. See the
cfe-commits email thread for r290169 for more on those.

According to the LangRef, the allocsize attribute only tells us about
the number of bytes that exist at the memory location pointed to by the
return value of a function. It does not necessarily mean that the
function will only ever allocate. So, we need to be very careful about
treating functions with allocsize as general allocation functions. This
patch makes us fully conservative in this regard, though I suspect that
we have room to be a bit more aggressive if we want.

This has a FIXME that can be fixed by a relatively straightforward
refactor; I just wanted to keep this patch minimal. If this sticks, I'll
come back and fix it in a few days.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290397 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/MemoryBuiltins.cpp
unittests/Analysis/CMakeLists.txt
unittests/Analysis/MemoryBuiltinsTest.cpp [new file with mode: 0644]