Author: Aleksandr Nogikh Date: 2026-02-24T14:22:38+01:00 New Revision: 173956e9c7ee50409a5302af8b6754068a6f1fdc
URL: https://github.com/llvm/llvm-project/commit/173956e9c7ee50409a5302af8b6754068a6f1fdc DIFF: https://github.com/llvm/llvm-project/commit/173956e9c7ee50409a5302af8b6754068a6f1fdc.diff LOG: [AllocToken] Test alloc-token code generation for __size_returning_new (#183049) The alloc-token-lower.c test only covered standard (and non-standard) malloc-annotated allocation function. Ensure that the code generation works as intended also for the standard malloc_span-annotated functions with the example of __size_returning_new. Added: Modified: clang/test/CodeGen/alloc-token-lower.c Removed: ################################################################################ diff --git a/clang/test/CodeGen/alloc-token-lower.c b/clang/test/CodeGen/alloc-token-lower.c index 2d87b02c6a288..9ab50ca7cd938 100644 --- a/clang/test/CodeGen/alloc-token-lower.c +++ b/clang/test/CodeGen/alloc-token-lower.c @@ -36,4 +36,20 @@ void *test_nonlibcall_malloc() { return nonstandard_malloc(sizeof(int)); } +// Ensure that the standard allocation functions annotated with malloc_span +// are properly instrumented as well. +typedef struct { + void *p; + size_t n; +} __sized_ptr_t; +__sized_ptr_t __size_returning_new(size_t size) __attribute__((malloc_span)); + +// CHECK-LABEL: @test_size_returning_new +// DEFAULT: call{{.*}} { ptr, i64 } @__alloc_token___size_returning_new(i64 noundef 4, i64 2689373973731826898){{.*}} !alloc_token [[META_INT]] +// FASTABI: call{{.*}} { ptr, i64 } @__alloc_token_2689373973731826898___size_returning_new(i64 noundef 4){{.*}} !alloc_token [[META_INT]] +void *test_size_returning_new() { + __sized_ptr_t ret = __size_returning_new(sizeof(int)); + return ret.p; +} + // CHECK: [[META_INT]] = !{!"int", i1 false} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
