Skip to content

[lldb] Directly access object variable in GetObjectPointerValueObject (NFC)#193120

Open
kastiglione wants to merge 1 commit intollvm:mainfrom
kastiglione:lldb-Directly-access-object-variable-in-GetObjectPointerValueObject-NFC
Open

[lldb] Directly access object variable in GetObjectPointerValueObject (NFC)#193120
kastiglione wants to merge 1 commit intollvm:mainfrom
kastiglione:lldb-Directly-access-object-variable-in-GetObjectPointerValueObject-NFC

Conversation

@kastiglione
Copy link
Copy Markdown
Contributor

@kastiglione kastiglione commented Apr 21, 2026

The GetObjectPointerValueObject function does not need full variable path expressions, or any of its functionality. This function simply gets the value of this or self.

@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 21, 2026

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

Changes

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

1 Files Affected:

  • (modified) lldb/source/Expression/UserExpression.cpp (+8-9)
diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index d39bcced48390..537a9cc4c4e35 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -35,11 +35,13 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadPlan.h"
 #include "lldb/Target/ThreadPlanCallUserExpression.h"
+#include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/ValueObject/ValueObjectConstResult.h"
+#include "lldb/lldb-enumerations.h"
 #include "llvm/BinaryFormat/Dwarf.h"
 
 using namespace lldb_private;
@@ -108,16 +110,13 @@ lldb::ValueObjectSP UserExpression::GetObjectPointerValueObject(
     return {};
   }
 
-  lldb::VariableSP var_sp;
-  lldb::ValueObjectSP valobj_sp;
+  if (auto var_list_sp = frame_sp->GetInScopeVariableList(false))
+    if (auto var_sp =
+            var_list_sp->FindVariable(ConstString(object_name), false))
+      return frame_sp->GetValueObjectForFrameVariable(var_sp,
+                                                      lldb::eNoDynamicValues);
 
-  return frame_sp->GetValueForVariableExpressionPath(
-      object_name, lldb::eNoDynamicValues,
-      StackFrame::eExpressionPathOptionCheckPtrVsMember |
-          StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
-          StackFrame::eExpressionPathOptionsNoSyntheticChildren |
-          StackFrame::eExpressionPathOptionsNoSyntheticArrayRange,
-      var_sp, err);
+  return {};
 }
 
 lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp,

@kastiglione
Copy link
Copy Markdown
Contributor Author

kastiglione commented Apr 21, 2026

With this PR, eExpressionPathOptionsNoFragileObjcIvar, eExpressionPathOptionsNoSyntheticChildren, and eExpressionPathOptionsNoSyntheticArrayRange become no longer used, and dead code. I have a follow up PR ready to remove those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants