[Lldb-commits] [lldb] [lldb] Improve diagnostic when a variable being assigned isn't an lvalue (PR #216624)
Alexsander Borges Damaceno via lldb-commits
lldb-commits at lists.llvm.org
Sun Aug 16 19:42:23 PDT 2026
https://github.com/AlexsanderDamaceno created https://github.com/llvm/llvm-project/pull/216624
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
>From ca59ccf0a2534cd2485debeb415901e2ceced74e Mon Sep 17 00:00:00 2001
From: AlexsanderDamaceno <aemgbo at gmail.com>
Date: Sun, 16 Aug 2026 23:26:09 -0300
Subject: [PATCH] [lldb] Improve diagnostic when a variable being assigned
isn't an lvalue
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 opertion was not done,
so this patch add a note for cases where the lvalue does not have a memory location.
---
lldb/source/Expression/Materializer.cpp | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index 51e95d3376f72..8a800d7b454ee 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -648,12 +648,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;
}
}
More information about the lldb-commits
mailing list