[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 20:02:18 PDT 2026
https://github.com/AlexsanderDamaceno updated https://github.com/llvm/llvm-project/pull/216624
>From 8f44d1a6c0bb8c3bbb6548dd5bc4e43daa0e07e5 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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index 51e95d3376f72..219540756bf54 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -648,6 +648,14 @@ 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()) {
More information about the lldb-commits
mailing list