[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 08:56:09 PDT 2023


Endilll wrote:

> when does someone have an enum value that they don't intend to ever be in the enum

In my previous comments (https://github.com/llvm/llvm-project/pull/69104#issuecomment-1771167758, https://github.com/llvm/llvm-project/pull/69104#issuecomment-1771204043) I provided an example of `StoredNameKind` enum that has enumerators 0 through 8 (9 total, 4 bits to store), but we store it in a bit-fields of width 3, because the last enumerator is there to count other enumerators, and is used for offset purposes. If we apply `-Wbitfield-enum-conversion` to it as-is, we get a false-positive: https://godbolt.org/z/4xPs6qPTY.

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


More information about the cfe-commits mailing list