[Lldb-commits] [lldb] [lldb] Update dwim-print to support limited variable expression paths (PR #117452)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 2 11:16:46 PST 2024


================
@@ -151,10 +151,23 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
     result.SetStatus(eReturnStatusSuccessFinishResult);
   };
 
-  // First, try `expr` as the name of a frame variable.
-  if (frame) {
-    auto valobj_sp = frame->FindVariable(ConstString(expr));
-    if (valobj_sp && valobj_sp->GetError().Success()) {
+  // First, try `expr` as a _limited_ frame variable expression path: only the
+  // dot operator (`.`) is permitted for this case.
+  //
+  // This is limited to support only unambiguous expression paths. Of note,
+  // expression paths are not attempted if the expression contain either the
+  // arrow operator (`->`) or the subscript operator (`[]`). This is because
+  // both operators can be overloaded in C++, and could result in ambiguity in
+  // how the expression is handled. Additionally, `*` and `&` are not supported.
+  bool try_variable_path = expr.find_first_of("*&->[]") == StringRef::npos;
----------------
kastiglione wrote:

done

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


More information about the lldb-commits mailing list