[all-commits] [llvm/llvm-project] 08a873: [lldb][Python] Inline `lldb_iter` for better type ...

Nerixyz via All-commits all-commits at lists.llvm.org
Tue Aug 4 11:16:56 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 08a8739ac89a27c7dbd0349266611ca94866ae2f
      https://github.com/llvm/llvm-project/commit/08a8739ac89a27c7dbd0349266611ca94866ae2f
  Author: Nerixyz <nerixdev at outlook.de>
  Date:   2026-08-04 (Tue, 04 Aug 2026)

  Changed paths:
    M lldb/bindings/interface/SBAddressRangeListExtensions.i
    M lldb/bindings/interface/SBBreakpointExtensions.i
    M lldb/bindings/interface/SBBreakpointListExtensions.i
    M lldb/bindings/interface/SBCompileUnitExtensions.i
    M lldb/bindings/interface/SBDebuggerExtensions.i
    M lldb/bindings/interface/SBFileSpecListExtensions.i
    M lldb/bindings/interface/SBFrameListExtensions.i
    M lldb/bindings/interface/SBInstructionListExtensions.i
    M lldb/bindings/interface/SBModuleExtensions.i
    M lldb/bindings/interface/SBModuleSpecListExtensions.i
    M lldb/bindings/interface/SBProcessExtensions.i
    M lldb/bindings/interface/SBProcessInfoListExtensions.i
    M lldb/bindings/interface/SBSectionExtensions.i
    M lldb/bindings/interface/SBStringListExtensions.i
    M lldb/bindings/interface/SBSymbolContextListExtensions.i
    M lldb/bindings/interface/SBTargetExtensions.i
    M lldb/bindings/interface/SBThreadCollectionExtensions.i
    M lldb/bindings/interface/SBThreadExtensions.i
    M lldb/bindings/interface/SBTypeEnumMemberExtensions.i
    M lldb/bindings/interface/SBTypeExtensions.i
    M lldb/bindings/interface/SBUnixSignalsExtensions.i
    M lldb/bindings/interface/SBValueExtensions.i
    M lldb/bindings/interface/SBValueListExtensions.i
    M lldb/bindings/python/python-extensions.swig
    M lldb/bindings/python/python.swig

  Log Message:
  -----------
  [lldb][Python] Inline `lldb_iter` for better type inference (#214000)

Currently, the `lldb_iter` helper is used for providing `__iter__` in
the Python bindings:
```python
def lldb_iter(obj, getsize, getelem):
    """A generator adaptor to support iteration for lldb container objects."""
    size = getattr(obj, getsize)
    elem = getattr(obj, getelem)
    for i in range(size()):
        yield elem(i)
```

A type checker or LSP can't see through this function. Currently, that's
no problem, because it doesn't know the return type of any Swig wrapper,
but when we add type annotations (hopefully with Swig 4.5 in #213463),
`__iter__` remains untyped. So iterating through the wrappers won't show
the correct type.

As the functionality is fairly simple, it's easier to inline it. That's
what this PR does. Then a type checker can infer the return type.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list