llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Alexsander Borges Damaceno (AlexsanderDamaceno)

<details>
<summary>Changes</summary>

In some cases, when a binary is compiled with certain optimization flags, a 
variable may not have a memory location.

For example, a local variable may have its location represented in a register 
due to an optimization performed during compilation.

Since the current message is generic:

**"error: Couldn't apply expression side effects : couldn't write the new 
contents of var back into the variable"**

it could not make a clear why the write operation was not done, so this patch 
add a note for cases where the lvalue does not have a memory location.

Bug link: https://github.com/llvm/llvm-project/issues/130701

---
Full diff: https://github.com/llvm/llvm-project/pull/216624.diff


1 Files Affected:

- (modified) lldb/source/Expression/Materializer.cpp (+11-2) 


``````````diff
diff --git a/lldb/source/Expression/Materializer.cpp 
b/lldb/source/Expression/Materializer.cpp
index a53e3b50c8aab..f960224619d7c 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -649,12 +649,21 @@ class EntityVariableBase : public Materializer::Entity {
       Status set_error;
 
       if (actually_write) {
+        if (!valobj_sp->CanSetValue()) {
+          err = Status::FromErrorStringWithFormatv(
+              "couldn't write the new contents of {0} back into the "
+              "variable\nnote: Left operand of assignment is not an lvalue",
+              GetName());
+          return;
+        }
+
         valobj_sp->SetData(data, set_error);
 
         if (!set_error.Success()) {
           err = Status::FromErrorStringWithFormatv(
-              "couldn't write the new contents of {0} back into the variable",
-              GetName());
+              "couldn't write the new contents of {0} back into the "
+              "variable\nnote: {1}",
+              GetName(), set_error.AsCString());
           return;
         }
       }

``````````

</details>


https://github.com/llvm/llvm-project/pull/216624
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to