Page MenuHomePhabricator

[lldb] Encode `bool` as unsigned int
ClosedPublic

Authored by werat on May 18 2021, 5:44 AM.

Details

Summary

bool is considered to be unsigned according to std::is_unsigned<bool>::value (and Type::GetTypeInfo). Encoding it as signed int works fine for normal variables and fields, but breaks when reading the values of boolean bitfields. If the field is declared as bool b : 1 and has a value of 0b1, the call to SBValue::GetValueAsSigned() will return -1.

Diff Detail

Event Timeline

werat requested review of this revision.May 18 2021, 5:44 AM
werat created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2021, 5:44 AM
teemperor accepted this revision.May 18 2021, 6:12 AM

Nice, and it's not even my birthday. Just some nits that don't need another round of review.

lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
21

Please land that as it's own commit (from what I understand from the bug report this worked before and you just remove the skipIf here)

134

You might want to assert that bb.IsValid() after this call (otherwise the GetValueAs* calls just return 0 and that's a confusing error).

This revision is now accepted and ready to land.May 18 2021, 6:12 AM
werat updated this revision to Diff 346161.EditedMay 18 2021, 6:38 AM

Keep @skipIfWindows for now
Add more checks in tests

werat marked 2 inline comments as done.May 18 2021, 6:39 AM

Thanks for a quick review!

lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
21

Okay, will submit this in a follow up commit

This revision was landed with ongoing or failed builds.May 19 2021, 6:33 AM
This revision was automatically updated to reflect the committed changes.
werat marked an inline comment as done.