[clang] [Clang][Sema] Support 'counted_by' attribute on FAM/pointers in anonymous unions (PR #171996)

Yeoul Na via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 14 09:52:49 PST 2026


https://github.com/rapidsna requested changes to this pull request.

For __counted_by to work on a union, one of the following must be true:

Homogeneous Sizes: All members of the union must have the exact same sizeof().
Byte-Size Semantics: The attribute would need to be __sized_by.

Plus, I'm assuming if you have a union field that has `counted_by` or `sized_by`, all of the fields need the same annotation following the above rule. 

Requesting changes to add these restrictions.

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


More information about the cfe-commits mailing list