[clang] [Clang] Add __builtin_counted_by_ref builtin (PR #114495)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 15:54:54 PST 2024
================
@@ -16,6 +16,8 @@ void test1(struct fam_struct *ptr, int size, int idx) {
*__builtin_counted_by_ref(ptr->array) = size; // ok
*__builtin_counted_by_ref(&ptr->array[idx]) = size; // ok
+ *__builtin_counted_by_ref(&ptr->array) = size; // ok
----------------
bwendling wrote:
`*__builtin_counted_by_ref(ptr->array[idx]) = size;` doesn't work because the builtin requires a pointer to the FAM. (If you meant `&ptr->array[idx]`, that does work.)
I don't have any use case for `&ptr->array` or the like. I just don't want to be overly restrictive on what's considered a valid argument to the builtin. I think I'll do a comparison with gcc's version and see what they accept. We can match them.
https://github.com/llvm/llvm-project/pull/114495
More information about the cfe-commits
mailing list