fix: C and C++ extractor drops functions whose declarator has an unhandled shape
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with findFunctionDeclarator in internal/indexer/mainstream/cextract/cextract.go and compare its handled wrappers with the dropped shapes in the issue. Reproduce the name-side parentheses case with the provided shapes.cpp, then run codegraph init and codegraph callers foo; repeat for the other shapes. Done means each shape produces a function node with parameters and a caller result, or is recorded as a known limitation in docs/LANGUAGE-CAPABILITY-MATRIX.md.
Written by the indexing model from the issue text.
Description
What happens
The C and C++ extractor drops every function whose declarator is not a handled wrapper. findFunctionDeclarator in internal/indexer/mainstream/cextract/cextract.go:586 unwraps only pointer_declarator, array_declarator, reference_declarator and parenthesized_declarator. Any other node returns nil, so the declaration gets no function node. The extractor logs nothing.
A suite review of branch fix/360-cpp-reference-return found this (finding QUAL-8, CONFIRMED). That branch fixes #360 for reference_declarator only. The shapes below also drop on main.
The reviewer named these shapes as dropped without a node:
- A parenthesized declarator around the name, for example
int (foo)(int a);. - An attributed declarator (
attributed_declarator), for example with[[nodiscard]]placed on the declarator. - A function that returns a function pointer, for example
int (*getfn(int))(char);. - A function typedef, for example
typedef int fn_t(int a);. - A template declaration (
template_declaration) that wraps a function.
The template shape is already a documented limitation. docs/LANGUAGE-CAPABILITY-MATRIX.md line 206 and internal/indexer/mainstream/cextract/types.go line 126 both list it. The matrix does not list the other four shapes.
Whether a function typedef gets a function node is an open question. Related: #360 (reference returns) and #354 (extern "C" blocks).
What you expected instead
Each shape gets a function node with its parameters, and codegraph callers finds a call to it from a one-file fixture. For any shape, docs/LANGUAGE-CAPABILITY-MATRIX.md can instead list it as a known limitation.
Steps to reproduce
This reproduces the name-side parentheses shape. Each other shape needs the same steps with its own declaration.
-
In an empty directory, create
shapes.cpp:int (foo)(int a) { return a; } int main() { return foo(1); } -
Run
codegraph init. -
Run
codegraph callers foo.
Expected: main is listed as a caller of foo. Actual output is not recorded yet for any shape, so each shape needs its own run.
Version
Built from source at commit cf975c47 (branch fix/360-cpp-reference-return).
Platform
macOS, Darwin 27.2.0
How did you install it?
Built from source
Languages in the affected repository
C and C++. The extractor is internal/indexer/mainstream/cextract/. The matrix documents the template gap, but not the other four shapes.
Before submitting
- I searched existing issues and this is not a duplicate
- I reviewed the capability matrix and this is not a documented limitation
- This is not a security vulnerability
🤖 Generated with Claude Code
- Dominant language
- Go
- Stars
- 0
- Forks
- 0
- Avg merge
- 5h 16m
- Merged PRs (30d)
- 107
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from seanb4t/codegraph-go
-
area:indexer bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seanb4t/codegraph-go#385 ·
Maintainers usually reply within 1 day
-
chore needs-triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
seanb4t/codegraph-go#380 ·
Maintainers usually reply within 1 day
-
chore needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
seanb4t/codegraph-go#379 ·
Maintainers usually reply within 1 day
-
chore needs-triage
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
seanb4t/codegraph-go#362 ·
Maintainers usually reply within 1 day
-
area:query bug priority:low spec-needed
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
seanb4t/codegraph-go#355 ·
Maintainers usually reply within 1 day
All issues in seanb4t/codegraph-go
Similar issues
-
enhancement exporter/awskinesis needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
open-telemetry/opentelemetry-collector-contrib#53334 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
erigontech/erigon#26523 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
SocialGouv/iterion#3376 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
seaweedfs/seaweedfs#12740 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day