]> granicus.if.org Git - clang/commit
[analyzer] MallocChecker: Suppress false positives in shared pointers.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 21:19:33 +0000 (21:19 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 27 Feb 2018 21:19:33 +0000 (21:19 +0000)
commitfa5cf4d66333673688787dc95c94fe66c9da6446
treecaf91f3a28c01ed501940770d77067cef8f448c1
parent8465e3a177220a85206c4a5d071e27085a3bdcb1
[analyzer] MallocChecker: Suppress false positives in shared pointers.

Throw away MallocChecker warnings that occur after releasing a pointer within a
destructor (or its callees) after performing C11 atomic fetch_add or fetch_sub
within that destructor (or its callees).

This is an indication that the destructor's class is likely a
reference-counting pointer. The analyzer is not able to understand that the
original reference count is usually large enough to avoid most use-after-frees.

Even when the smart pointer is a local variable, we still have these false
positives that this patch suppresses, because the analyzer doesn't currently
support atomics well enough.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326249 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
test/Analysis/NewDelete-atomics.cpp [new file with mode: 0644]