Skip to content

Fix stubtest + bind AbstractStateManager dict-protocol#49

Merged
bjjwwang merged 1 commit intoSVF-tools:mainfrom
bjjwwang:sync-llvm-21
Apr 30, 2026
Merged

Fix stubtest + bind AbstractStateManager dict-protocol#49
bjjwwang merged 1 commit intoSVF-tools:mainfrom
bjjwwang:sync-llvm-21

Conversation

@bjjwwang
Copy link
Copy Markdown
Collaborator

The previous sync (51543e8) added pysvf.AbstractStateManager, AbstractInterpretation and Options to the binary but left the .pyi stub declaring the methods that the same commit removed from AbstractState. The release.yml stubtest job catches that drift and was failing on the sync-llvm-21 PR. This commit:

pybind/AE.cpp:

  • Add setitem (delegates to updateAbstractState) and contains (delegates to hasAbstractState) on AbstractStateManager so Python code can use it as a drop-in replacement for the old post_abs_trace dict (Software-Security-Analysis Assignment-3 relies on this to wire the stateMgr in as the post-trace backing store).

pysvf/pysvf.pyi:

  • Drop the seven AbstractState methods that the upstream Semi-Sparse refactor moved off the class: getElementIndex, getByteOffset, getPointeeElement, storeValue, loadValue, getAllocaInstByteSize, getGepObjAddrs.
  • Add type stubs for AbstractStateManager (full surface, including the dict-protocol additions), AbstractInterpretation, and Options so they are visible to mypy/pyright users.
  • Add GepStmt.getStructFieldOffset matching the new lambda binding.

stubtest_allowlist.txt:

  • Whitelist the new pybind classes (AbstractStateManager, AbstractInterpretation, Options) using the same pysvf.<Name> shape that already exempts AbstractState/AbstractValue/etc. The pybind11 metaclass + auto-generated __init__(*args, **kwargs) always trip stubtest unless the class is allow-listed.

Verified locally: stubtest reports Success: no issues found in 4 modules.

The previous sync (51543e8) added pysvf.AbstractStateManager,
AbstractInterpretation and Options to the binary but left the .pyi stub
declaring the methods that the same commit removed from AbstractState.
The release.yml `stubtest` job catches that drift and was failing on the
sync-llvm-21 PR. This commit:

pybind/AE.cpp:
- Add __setitem__ (delegates to updateAbstractState) and __contains__
  (delegates to hasAbstractState) on AbstractStateManager so Python code
  can use it as a drop-in replacement for the old `post_abs_trace` dict
  (Software-Security-Analysis Assignment-3 relies on this to wire the
  stateMgr in as the post-trace backing store).

pysvf/pysvf.pyi:
- Drop the seven AbstractState methods that the upstream Semi-Sparse
  refactor moved off the class: getElementIndex, getByteOffset,
  getPointeeElement, storeValue, loadValue, getAllocaInstByteSize,
  getGepObjAddrs.
- Add type stubs for AbstractStateManager (full surface, including the
  dict-protocol additions), AbstractInterpretation, and Options so they
  are visible to mypy/pyright users.
- Add GepStmt.getStructFieldOffset matching the new lambda binding.

stubtest_allowlist.txt:
- Whitelist the new pybind classes (AbstractStateManager,
  AbstractInterpretation, Options) using the same `pysvf.<Name>` shape
  that already exempts AbstractState/AbstractValue/etc. The pybind11
  metaclass + auto-generated `__init__(*args, **kwargs)` always trip
  stubtest unless the class is allow-listed.

Verified locally: stubtest reports `Success: no issues found in 4 modules`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bjjwwang bjjwwang merged commit b31f8b0 into SVF-tools:main Apr 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant