Repository navigation
Scratch/riel/callchain abc - #163
Merged
rikvanriel merged 4 commits intoNov 29, 2026
Merged
Conversation
A member call such as `w.process(1)` records a dispatch site naming its receiver's type, but the reverse lookup only joins sites to functions installed in a struct or trait slot. Inherent methods are never installed anywhere, so they stay unreachable: `callers Widget::process` reports that nothing calls it, and the same gap hides every `s.im()`-style call. A site whose receiver type names an owner now joins that owner's member. A typed site with member M reaches the functions named M whose stored qualifier addresses the receiver type, through the same suffix rule qualified lookups already use. Slots hold no rows for inherent methods, so the reverse join gains one lookup into the functions table instead of new storage. A site the slot or trait join already answered keeps its row, and the typed join adds no second row; several definitions matching one site still answer once. A site stating no receiver type joins nothing, since member names alone over-match. The joined row reads as a definition (`defined in Widget::process at widget.cpp:2, 1 definition`), never as an installation. `callchain` lists the joined rows under a section of their own. Virtual dispatch stays out: the index holds no base/derived graph, so a static receiver keeps joining only its own type. Overload arity stays out: a site joins every same-owner overload. Destructors, member-template calls and explicit conversion-operator calls stay out: capture records no site for them, so no join can reach them. Tested with a fixture holding a Widget method plus its driver, a Base/Derived pair called through a static receiver, three owners defining one member with typed, auto and template-param callers beside them, and a Rust trait with an inherent method: query before after `callers Widget::process` no callers driver `callers Base::v` no callers vuser `callers Derived::v` no callers no callers `callers Nav::process_afc` no callers param_user, typed_user `callers Wefax::process_afc` no callers no callers `callers tm` ruser ruser, once `callers S::im` no callers ruser New tests in tests/typed_member_calls.rs cover the fail-on-base query and each guard; a unit test pins the halves rule the join relies on.
Forward queries miss what the reverse direction already finds. A call such as `w.process(1)` records a dispatch site naming its receiver's type, but the forward lookup only joins sites to installed slots. Inherent methods are never installed anywhere, so `calls driver` reports that it calls nothing and `callchain ruser` reports it as isolated. A site whose receiver type names an owner reaches that owner's member in both directions now: the forward join runs the reverse join's owner check from the site's member and receiver type instead of from a queried name. A site the slot join already answered keeps its row, and a site stating no receiver type joins nothing, since member names alone over-match. `callchain` and find_callchain list the joined rows through their existing Dispatches section; `calls` and find_calls gain a section listing only the typed rows; installed targets stay with the chain's section. `callchain` no longer reports a function that lists dispatches as isolated. A joined row names qualified definitions (`Widget::process`), never installations, and overloads sharing one qualified name answer as one target. Probed with a Widget method plus its driver, a Base/Derived pair called through a static receiver, three owners defining one member with typed, auto and template-param callers beside them, and a Rust trait with an inherent method, indexed once per side and queried through the CLI and MCP: query before after `calls driver` calls nothing Widget::process `calls typed_user`, `calls param_user` no row Nav::process_afc `calls vuser` no row Base::v `calls ruser` (im) calls nothing shapes::S::im `calls ruser` (tm) calls nothing shapes::<S as Tr>::tm `callchain driver`, `callchain ruser` isolated Dispatches `callchain typed_user`, `callchain vuser` isolated Dispatches `callchain duser` (slot dispatch row) isolated no isolated line slot/trait/C/Python/Zig `calls`, auto_user unchanged unchanged New tests in tests/typed_member_calls.rs extend the fixture forward: resolve-level pins for the join, the owner, and the untyped guard, plus display pins for the new calls section. With the join stubbed, the four feature tests fail while the guard and all reverse tests pass.
The call site records only the member name, so a two-argument call joins whichever overload the file lists first. `callers Widget::process` answers about the one-argument overload and still lists the two-argument caller. Where the site carries its argument count, the member join prefers the same-count overload, and an answer lists only callers of the definition it is about. The extractor counts the arguments of each member call into a new nullable column on the site row; sites that name no call carry none and fall back to the first definition in the tree. The count lives in no stored row, so an index written by an older version reads every file again; the schema version becomes 15 and the extractor version becomes 11. The reverse answer keeps only rows whose definition is the one it is about: listing a counted site under another overload's heading would credit this overload with another overload's callers. A counted site now reaches one overload, so its row names one definition: under `callers Widget::process`, one's row reads "1 definition" where it read "2 definitions". Bare names spanning several owners aggregate across the definitions they address, so the scoping stops there and the bare answer keeps every row. Where no same-count definition matches, the join falls back to the first definition in the tree, so a default argument or a pack still reaches. The ambiguity note for same-owner, same-file definitions now says the arguments pick the overload; only the count is recorded here, not their types. Tested by indexing a probe repo (a two-overload widget plus the receiver and owner guard fixtures) once with the binary before the change and once with this commit's, then running the caller and chain queries over both, in the CLI and in the MCP server: query before after `callers Widget::process` lists driver no callers `callchain Widget::process` driver reaches it isolated `callchain`/`calls driver` unchanged unchanged `callers Nav::process_afc`, `tm`, `S::im` unchanged unchanged `callchain ruser`, `callers Base::v` unchanged unchanged MCP `find_callers Widget::process` lists driver no callers MCP `find_callchain Widget::process` driver reaches it isolated Out of scope: full signatures (types, defaults, conversions); free-function overloads, whose calls are plain edges that carry no count; the forward chain, which lists the same text either way; and callers of an overload the resolution does not pick, which no reverse heading lists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some changes to produce better call chains for userspace C++ programs, tested with fldigi and vllm.