[analyzer] pr39348: MallocChecker: Realize that sized delete isn't custom delete.
authorArtem Dergachev <artem.dergachev@gmail.com>
Thu, 1 Nov 2018 00:43:35 +0000 (00:43 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 1 Nov 2018 00:43:35 +0000 (00:43 +0000)
commit32c0c85382ab63ff38f58b41e904bbfe733d9a60
tree10408bc41a0da929b0ed00cb0307516b6911d7cf
parenta9f900561ed7d7c8738c32b68588c9ec5e6c1f5f
[analyzer] pr39348: MallocChecker: Realize that sized delete isn't custom delete.

MallocChecker no longer thinks that operator delete() that accepts the size of
the object to delete (available since C++14 or under -fsized-deallocation)
is some weird user-defined operator. Instead, it handles it like normal delete.

Additionally, it exposes a regression in NewDelete-intersections.mm's
testStandardPlacementNewAfterDelete() test, where the diagnostic is delayed
from before the call of placement new into the code of placement new
in the header. This happens because the check for pass-into-function-after-free
for placement arguments is located in checkNewAllocator(), which happens after
the allocator is inlined, which is too late. Move this use-after-free check
into checkPreCall instead, where it works automagically because the guard
that prevents it from working is useless and can be removed as well.

This commit causes regressions under -analyzer-config
c++-allocator-inlining=false but this option is essentially unsupported
because the respective feature has been enabled by default quite a while ago.

Differential Revision: https://reviews.llvm.org/D53543

llvm-svn: 345802
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/test/Analysis/NewDelete-custom.cpp
clang/test/Analysis/NewDelete-sized-deallocation.cpp [new file with mode: 0644]