[all-commits] [llvm/llvm-project] cedb44: [libc++] Pass type information down to __libcpp_al...
Louis Dionne via All-commits
all-commits at lists.llvm.org
Mon Jan 13 06:10:58 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cedb44af53f195135e8e8de98f161048d19f8857
https://github.com/llvm/llvm-project/commit/cedb44af53f195135e8e8de98f161048d19f8857
Author: Louis Dionne <ldionne.2 at gmail.com>
Date: 2025-01-13 (Mon, 13 Jan 2025)
Changed paths:
M libcxx/include/CMakeLists.txt
M libcxx/include/__functional/function.h
M libcxx/include/__memory/allocator.h
R libcxx/include/__memory/builtin_new_allocator.h
M libcxx/include/__memory/unique_temporary_buffer.h
M libcxx/include/__new/allocate.h
M libcxx/include/__string/constexpr_c_functions.h
A libcxx/include/__utility/element_count.h
M libcxx/include/__utility/small_buffer.h
M libcxx/include/module.modulemap
M libcxx/src/memory_resource.cpp
M libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
Log Message:
-----------
[libc++] Pass type information down to __libcpp_allocate (#118837)
Currently, places where we call __libcpp_allocate must drop type
information on the ground even when they actually have such information
available. That is unfortunate since some toolchains and system
allocators are able to provide improved security when they know what
type is being allocated.
This is the purpose of http://wg21.link/p2719, where we introduce a new
variant of `operator new` which takes a type in its interface. A
different but related issue is that `std::allocator` does not honor any
in-class `T::operator new` since it is specified to call the global
`::operator new` instead.
This patch closes the gap to make it trivial for implementations that
provide typed memory allocators to actually benefit from that
information in more contexts, and also makes libc++ forward-compatible
with future proposals that would fix the existing defects in
`std::allocator`. It also makes the internal allocation API higher level
by operating on objects instead of operating on bytes of memory.
Since this is a widely-used function and making this a template could
have an impact on debug info sizes, I tried minimizing the number of
templated layers by removing `__do_deallocate_handle_size`, which was
easy to replace with a macro (and IMO this leads to cleaner code).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list