[lldb] Fix Scalar::GetData for non-multiple-of-8-bits values (#90846)
It was aligning the byte size down. Now it aligns up. This manifested itself as SBTypeStaticField::GetConstantValue returning a zero-sized value for `bool` fields (because clang represents bool as a 1-bit value). I've changed the code for float Scalars as well, although I'm not aware of floating point values that are not multiples of 8 bits.
This commit is contained in:
@@ -52,6 +52,19 @@ class TypeAndTypeListTestCase(TestBase):
|
||||
self.DebugSBValue(value)
|
||||
self.assertEqual(value.GetValueAsSigned(), 47)
|
||||
|
||||
static_constexpr_bool_field = task_type.GetStaticFieldWithName(
|
||||
"static_constexpr_bool_field"
|
||||
)
|
||||
self.assertTrue(static_constexpr_bool_field)
|
||||
self.assertEqual(
|
||||
static_constexpr_bool_field.GetName(), "static_constexpr_bool_field"
|
||||
)
|
||||
self.assertEqual(static_constexpr_bool_field.GetType().GetName(), "const bool")
|
||||
|
||||
value = static_constexpr_bool_field.GetConstantValue(self.target())
|
||||
self.DebugSBValue(value)
|
||||
self.assertEqual(value.GetValueAsUnsigned(), 1)
|
||||
|
||||
static_mutable_field = task_type.GetStaticFieldWithName("static_mutable_field")
|
||||
self.assertTrue(static_mutable_field)
|
||||
self.assertEqual(static_mutable_field.GetName(), "static_mutable_field")
|
||||
|
||||
@@ -28,6 +28,7 @@ public:
|
||||
union U {
|
||||
} u;
|
||||
static constexpr long static_constexpr_field = 47;
|
||||
static constexpr bool static_constexpr_bool_field = true;
|
||||
static int static_mutable_field;
|
||||
Task(int i, Task *n):
|
||||
id(i),
|
||||
|
||||
Reference in New Issue
Block a user