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

Aperta
#368 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c, cpp, go
Ambito
devtools

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:indexer bug needs-triage
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

Lingua principale
Go
Stelle
0
Fork
0
Merge medio
7h 42m
PR unite (30g)
111

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di seanb4t/codegraph-go

Tutte le issue di seanb4t/codegraph-go

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.