[Lldb-commits] [lldb] [LLDB][Value] Require type size when reading a scalar (PR #153386)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 14 06:15:57 PDT 2025


================
@@ -347,6 +347,9 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
     else
       data.SetAddressByteSize(sizeof(void *));
 
+    if (!type_size)
+      return Status::FromErrorString("type does not have a size");
----------------
Michael137 wrote:

Looks like this is a regression from (https://github.com/llvm/llvm-project/pull/151350):
```
Author: Ilia Kuklin <ikuklin at accesssoftek.com>
Date:   Wed Aug 6 14:32:19 2025 +0500

    [lldb] Add `ValueObject::CreateValueObjectFromScalar` and fix `Scalar::GetData` (#151350)
    
    Add `ValueObject::CreateValueObjectFromScalar` function and adjust
    `Scalar::GetData` to be able to both extend and truncate the data bytes
    in Scalar to the specified size.
```

Previously we would return an error if `type_size` was unset.

So this pretty much brings us back to previous behaviour.

Any way we can test this in `lldb/unittests/Utility/ScalarTest.cpp`? I guess the tricky bit will be creating a type with invalid `byte_size`. Maybe with an incomplete AST type? Haven't looked at what's available in that test though

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


More information about the lldb-commits mailing list