fix: C and C++ extractor drops functions whose declarator has an unhandled shape
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Go
- 星标
- 0
- 派生
- 0
- 平均合并
- 7 小时 42 分钟
- 30 天内合并 PR
- 111
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
seanb4t/codegraph-go 的其他 Issue
-
chore needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
seanb4t/codegraph-go#380 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 2/5 1-3 小时 新手友好度 82/100
seanb4t/codegraph-go#379 ·
维护者通常 1 天内回复
-
area:query chore needs-triage spec-needed
难度 2/5 1-3 小时 新手友好度 74/100
seanb4t/codegraph-go#377 ·
维护者通常 1 天内回复
-
chore needs-triage
难度 1/5 1-3 小时 新手友好度 84/100
seanb4t/codegraph-go#362 ·
维护者通常 1 天内回复
-
area:query bug needs-triage
难度 2/5 1-3 小时 新手友好度 80/100
seanb4t/codegraph-go#355 ·
维护者通常 1 天内回复
查看 seanb4t/codegraph-go 的全部 Issue
相似的 Issue
-
go-vulnerability security-scan
难度 1/5 1 小时以内 新手友好度 84/100
teslashibe/agent-go#35 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
alecthomas/chroma#1498 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 8 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复