Skip to content

Scratch/riel/weak named match - #109

Merged
rikvanriel merged 2 commits into
facebookexperimental:mainfrom
rikvanriel:scratch/riel/weak-named-match
Nov 8, 2026
Merged

rikvanriel merged 2 commits into
facebookexperimental:mainfrom
rikvanriel:scratch/riel/weak-named-match

Conversation

@rikvanriel

Copy link
Copy Markdown
Contributor

Fix some more function parsing issues, specifically netdev_cmd_to_name has a #define right in the middle of it, which threw off the treesitter parser, resulting in the rest of the file being assigned to that one function.

A member-name match with no receiver type reaches every call through a
member of that name anywhere in the tree: bfa_msix, a sound codec and
the Rust syn parser all showed up as dispatchers of kernel functions
they cannot reach. The callers command already reports those as a
count, not as an answer; the reverse-chain section now does the same.
Sites that name the target outright still count as confident.

Adds an end to end test with a typed struct dispatch beside an
untyped same-named one: the typed site renders as an answer, the
untyped one is counted and not answered. The test fails with the old
rendering and passes with the new.
Matches stream in tree order, so a range that contains another claimed
the inner one's calls first and the covered sets kept the first claim.
A body the parser did not close (netdev_cmd_to_name spans 1921-13770
after an in-body define) then owned every call for eleven thousand
lines: it directly called 1033 functions, and every dispatch site in
the range was attributed to it, so callers deliver_skb named it and
the ip_rcv chain showed it instead of deliver_skb.

Parse first, attribute second: collect each match, run smallest span
first, and let each call byte belong to exactly one function. A GNU
nested function keeps its own calls instead of donating them outward.

A scoped kernel reindex shows netdev_cmd_to_name dropping from 1033
direct callees to 12 gap-region macros, deliver_skb's callers losing
it, and the ip_rcv chain naming deliver_skb and friends with the weak
same-named sites counted, not answered. The function row still spans
the parser's range; only attribution is fixed. Adds a nesting unit
test that fails with file order and passes innermost-first.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 8, 2026
@rikvanriel
rikvanriel merged commit 208d2d4 into facebookexperimental:main Nov 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant