diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2021-07-28 10:33:46 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2021-07-28 17:43:15 +0530 |
commit | 84606efb0c6b1c1598d5ec6b05544e71596663b5 (patch) | |
tree | cf703ac4b2312c424d3590d5cc935b5b74d0f797 /gcc/analyzer | |
parent | 54ec50bada94a8ff92edb04ee5216c27fa4bf942 (diff) | |
download | gcc-84606efb0c6b1c1598d5ec6b05544e71596663b5.zip gcc-84606efb0c6b1c1598d5ec6b05544e71596663b5.tar.gz gcc-84606efb0c6b1c1598d5ec6b05544e71596663b5.tar.bz2 |
analyzer: Recognize __builtin_free as a matching deallocator
Recognize __builtin_free as being equivalent to free when passed into
__attribute__((malloc ())), similar to how it is treated when it is
encountered as a call. This fixes spurious warnings in glibc where
xmalloc family of allocators as well as reallocarray, memalign,
etc. are declared to have __builtin_free as the free function.
gcc/analyzer/ChangeLog:
* sm-malloc.cc
(malloc_state_machine::get_or_create_deallocator): Recognize
__builtin_free.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/attr-malloc-1.c (compatible_alloc,
compatible_alloc2): New extern allocator declarations.
(test_9, test_10): New tests.
Diffstat (limited to 'gcc/analyzer')
-rw-r--r-- | gcc/analyzer/sm-malloc.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc index 9707a68..1d69d57 100644 --- a/gcc/analyzer/sm-malloc.cc +++ b/gcc/analyzer/sm-malloc.cc @@ -1511,7 +1511,8 @@ malloc_state_machine::get_or_create_deallocator (tree deallocator_fndecl) /* Reuse "free". */ deallocator *d; if (is_named_call_p (deallocator_fndecl, "free") - || is_std_named_call_p (deallocator_fndecl, "free")) + || is_std_named_call_p (deallocator_fndecl, "free") + || is_named_call_p (deallocator_fndecl, "__builtin_free")) d = &m_free.m_deallocator; else { |