[clang] [clang] Add clang::preferred_type attribute for bitfields (PR #69104)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 07:58:55 PDT 2023


Endilll wrote:

>>    @erichkeane I guess you'd be pretty happy if our enums were declared the following way:

>Not really? That doesn't gain us the 'we must change where this is stored' situation like a preferred_type attribute would/could. We MIGHT be able to get away with a comment on top of that with a list of places that needs to ALSO be changed, but we end up missing similar comments today anyway.

I meant `unsigned _BitInt(N)` underlying type to complement `preferred_type`'s check that a bit-field is wide enough. Otherwise such a check will have to incorporate heuristics to prevent false-positives for cases like the following: https://github.com/llvm/llvm-project/blob/180eae1f1e5a08595ed2278d93f01fb321284649/clang/include/clang/AST/DeclarationName.h#L174-L185
One might argue that this particular case might be resolved by transition to `PointerIntPair`, which is true. It's just the only case I was able to find. I have a recollection of an enum that ends with `Size` enumerator, possibly TableGen'ed, but I can't find it.

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


More information about the cfe-commits mailing list