[Lldb-commits] [lldb] [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 2 02:34:28 PST 2024


================
@@ -3194,16 +3194,19 @@ lldb::ValueObjectSP ValueObject::CastToBasicType(CompilerType type) {
       GetCompilerType().IsPointerType() || GetCompilerType().IsNullPtrType();
   bool is_float = GetCompilerType().IsFloat();
   bool is_integer = GetCompilerType().IsInteger();
+  ExecutionContext exe_ctx(GetExecutionContextRef());
 
   if (!type.IsScalarType()) {
-    m_error = Status::FromErrorString("target type must be a scalar");
-    return GetSP();
+    Status error = Status::FromErrorString("target type must be a scalar");
+    return ValueObjectConstResult::Create(
+        exe_ctx.GetBestExecutionContextScope(), error.Clone());
----------------
labath wrote:

```suggestion
    return ValueObjectConstResult::Create(
        exe_ctx.GetBestExecutionContextScope(), Status::FromErrorString("target type must be a scalar"));
```

If you really want to have a variable for this, then you can keep what you have and use `std::move` instead of `Clone`, but I think this is better (and I think Adrian would agree :) ).

This comment applies throughout the patch.

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


More information about the lldb-commits mailing list