[clang] [Clang] Implement the 'counted_by' attribute (PR #76348)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 17:05:07 PST 2024


bwendling wrote:

> > @kees, the issue should be fixed with the newest push.
> 
> Nice! This is so extremely close. It fixed all but 1 instance in the torture testing. The remaining seems to be union order sensitive. O_o This arrangement still reports non-zero for the `int count_bytes` one, unless I move it below the `signed char count_ints` counter:

This is due to it being a union. There's more than one field with a `counted_by` attribute, and we just use the first one we see...and importantly it's type. This obviously isn't correct and I can fix it. However, it does bring up an issue that I *don't* know how to fix. If you have something like:

```
printf("%zu\n", __builtin_dynamic_object_size(mi, 1));
```

we don't know out of hand whether to use the `count_bytes` or `count_ints` field to get the object size. I suggest in that case we should probably throw up our hands and give up. Thoughts?

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


More information about the cfe-commits mailing list