[compiler-rt] asan: refactor interceptor allocation/deallocation functions (PR #145087)

Justin King via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 06:44:54 PDT 2025


================
@@ -1007,13 +1007,8 @@ void PrintInternalAllocatorStats() {
   instance.PrintStats();
 }
 
-void asan_free(void *ptr, BufferedStackTrace *stack, AllocType alloc_type) {
----------------
jcking wrote:

Its mostly for consistency and ease of reading, especially with free_sized and free_aligned_sized incoming. For every public method related to allocation/deallocation we intercept, we expose exactly one function of the same name in `__asan` with `asan_` as the prefix. Right now memalign is used for all the AllocType and we are about to introduce FROM_ALIGNED_ALLOC. So we have an oddity where we have a 1:1, except for memalign which is special for some reason. The refacator moves the assignment of AllocType to be purely a detail of asan_allocator.cpp.

Its most just to simplify reading and ensure callers do not accidently mix up AllocType.

https://github.com/llvm/llvm-project/pull/145087


More information about the llvm-commits mailing list