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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 08:36:49 PDT 2023


erichkeane wrote:

> > See how on the assignment to a bitfield we check to make sure the largest value of the enum will fit in the bitfield? I'm saying I want us to do this EARLIER, on declaration with this attribute.
> 
> I totally do. Thank you for pointing out to `-Wbitfield-enum-conversion`! But you should be able to see in my example above that we need a way to exclude an enumerator from this check (in my example it's `[[clang::non_storable]]` applied to `UncommonNameKindOffset`), otherwise we'll get false-positives.

I don't see why that is necessary?  We don't have anything like that today for `-Wbitfield-enum-conversion`?  I have a hard time seeing the value of it, even for  `-Wbitfield-enum-conversion`, when does someone have an enum value that they don't intend to ever be in the enum?  

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


More information about the cfe-commits mailing list