[compiler-rt] asan: refactor interceptor allocation/deallocation functions (PR #145087)
Justin King via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 30 12:03:58 PDT 2025
================
@@ -83,128 +85,133 @@ enum class align_val_t: size_t {};
#if !SANITIZER_APPLE
CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size) {
- OPERATOR_NEW_BODY(FROM_NEW, false /*nothrow*/);
+ OPERATOR_NEW_BODY(false /*array*/, false /*nothrow*/);
}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size) {
- OPERATOR_NEW_BODY(FROM_NEW_BR, false /*nothrow*/);
+ OPERATOR_NEW_BODY(true /*array*/, false /*nothrow*/);
}
CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size, std::nothrow_t const &) {
- OPERATOR_NEW_BODY(FROM_NEW, true /*nothrow*/);
+ OPERATOR_NEW_BODY(false /*array*/, true /*nothrow*/);
}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size, std::nothrow_t const &) {
- OPERATOR_NEW_BODY(FROM_NEW_BR, true /*nothrow*/);
+ OPERATOR_NEW_BODY(true /*array*/, true /*nothrow*/);
}
CXX_OPERATOR_ATTRIBUTE
void *operator new(size_t size, std::align_val_t align) {
- OPERATOR_NEW_BODY_ALIGN(FROM_NEW, false /*nothrow*/);
+ OPERATOR_NEW_BODY_ALIGN(false /*array*/, false /*nothrow*/);
}
CXX_OPERATOR_ATTRIBUTE
void *operator new[](size_t size, std::align_val_t align) {
- OPERATOR_NEW_BODY_ALIGN(FROM_NEW_BR, false /*nothrow*/);
+ OPERATOR_NEW_BODY_ALIGN(true /*array*/, false /*nothrow*/);
----------------
jcking wrote:
The idea was to avoid allowing AllocType to be passed directly into the functions exposed by allocator.hpp, to avoid potential mismatch among callers. having a 1:1 mapping between intercepted allocation functions and functions in allocator.hpp starting with asan_ ensures all the logic for determing the AllocType is isolated to allocator.cpp. The boolean here is just so that there is one macro for all new/new[].
https://github.com/llvm/llvm-project/pull/145087
More information about the llvm-commits
mailing list