[Lldb-commits] [PATCH] D134493: [lldb][TypeSystemClang] Deduce lldb::eEncodingUint for unsigned enum types

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 23 03:10:20 PDT 2022


Michael137 added a comment.

In D134493#3811097 <https://reviews.llvm.org/D134493#3811097>, @labath wrote:

> In D134493#3810290 <https://reviews.llvm.org/D134493#3810290>, @Michael137 wrote:
>
>> Wasn't sure how to properly test this since the original reproducer technically relies on implementation-defined behaviour (i.e., initialising a bitfield with an out-of-range value). Suggestions are welcome
>
> I'm probably missing something, but what exactly is undefined about that test program? The number eight fits comfortably in four bits, and afaik it is a valid value for the `EnumVals` type because it has a fixed underlying type.
>
> Other than that, this seems fine to me.

Ah yes, absolutely true! Misinterpreted it from some of the other reproducers.
It's enough for the value we assign (here `8`) to be out of range of the bit-field (if it were signed). Since we previously treated
all bit-fields of enum type as signed, that would incorrectly left-fill with 1s.
I.e., if the bit-field were of width 16, then 32768 would sign-extend incorrectly. I'll update the test description accordingly


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134493/new/

https://reviews.llvm.org/D134493



More information about the lldb-commits mailing list