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

オープン
#368 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, cpp, go
領域
devtools

調査の方向性

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 の本文から書いたものです。

説明

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

主要言語
Go
スター
0
フォーク
0
平均マージ
7時間 42分
マージ済み PR(30日)
111

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

seanb4t/codegraph-go のほかの issue

seanb4t/codegraph-go の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。