[all-commits] [llvm/llvm-project] 41fddc: [lldb] Print empty enums as if they were unrecogni...

David Spickett via All-commits all-commits at lists.llvm.org
Wed Jul 3 06:48:16 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 41fddc4ec3302f125a5b84ae86c8027dedc89984
      https://github.com/llvm/llvm-project/commit/41fddc4ec3302f125a5b84ae86c8027dedc89984
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2024-07-03 (Wed, 03 Jul 2024)

  Changed paths:
    M lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
    M lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-missing-signature.test
    M lldb/unittests/ValueObject/DumpValueObjectOptionsTests.cpp

  Log Message:
  -----------
  [lldb] Print empty enums as if they were unrecognised normal enums (#97553)

Fixes #97514

Given this example:
```
enum E {};

int main()
{
    E x = E(0);
    E y = E(1);
    E z = E(2);
    return 0;
}
```
lldb used to print nothing for `x`, but `0x1` for `y` and `0x2` for `z`.

At first this seemed like the 0 case needed fixing but the real issue
here is that en enum with no enumerators was being detected as a
"bitfield like enum".

Which is an enum where all enumerators are a single bit value, or the
sum of previous single bit values.

For these we do not print anything for a value of 0, as we assume it
must be the remainder after we've printed the other bits that were set
(I think this is also unfortunate, but I'm not addressing that here).

Clearly an enum with no enumerators cannot be being used as a bitfield,
so check that up front and print it as if it's a normal enum where we
didn't match any of the enumerators. This means you now get:
```
(lldb) p x
(E) 0
(lldb) p y
(E) 1
(lldb) p z
(E) 2
```

Which is a change to decimal from hex, but I think it's overall more
consistent. Printing hex here was never a concious decision.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list