fix: C and C++ extractor drops functions whose declarator has an unhandled shape

Open
#368 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c, cpp, go
Domain
devtools

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

area:indexer bug priority:low spec-needed
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.

  1. In an empty directory, create shapes.cpp:

    int (foo)(int a) { return a; }
    int main() { return foo(1); }
    
  2. Run codegraph init.

  3. 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

https://claude.ai/code/session_0167DcyrN4PrZewitbjYLc9L

Dominant language
Go
Stars
0
Forks
0
Avg merge
5h 16m
Merged PRs (30d)
107

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from seanb4t/codegraph-go

All issues in seanb4t/codegraph-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.