[Lldb-commits] [lldb] [lldb] Add lookup by name to SBValue.child (PR #118814)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 6 10:34:26 PST 2024


================
@@ -23,6 +23,13 @@ STRING_EXTENSION_OUTSIDE(SBValue)
                     if -count <= key < count:
                         key %= count
                         return self.sbvalue.GetChildAtIndex(key)
+                elif isinstance(key, str):
+                    if child := self.sbvalue.GetChildMemberWithName(key):
+                        return child
+                    # Support base classes, which are children but not members.
+                    for child in self.sbvalue:
+                        if child.name == key:
+                            return child
----------------
kastiglione wrote:

I agree with your opinions. I think I'd like to avoid introducing complexities in interface/consistency.

Should I change this PR to introduce a new `member` property? Or should `value.child[name]` be documented as meaning only `value.GetChildMemberWithName(name)`? cc @jimingham 

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


More information about the lldb-commits mailing list