fix(cl): preserve imports for types initialized across files
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start with the minimal reproduction: a forward declaration in a.h and the definition in b.h, mapped to separate outputs through GoFileOf. Check which Go file receives the imports for Point, and why c.Int and unsafe.Pointer end up in a file without them. Pull request #1042 is already open against this issue, so coordinate with it first. Done means a.go compiles with the right imports and aliases stay consistent regardless of traversal order.
索引モデルが issue の本文から書いたものです。
説明
Summary
When a C/C++ record is declared in one header and defined in another header,
llcppg can generate the record in the Go file that owns the declaration while
collecting its field types from the definition's Go file. The generated type
then refers to imported types such as c.Int or unsafe.Pointer, but the
imports are attached to the wrong Go file.
Depending on source/file traversal order, this produces either missing imports
or inconsistent aliases such as c1.Int and unsafe1.Pointer.
Minimal Reproduction
a.h:
#pragma once
struct point;
b.h:
#pragma once
struct point {
int x;
void *data;
};
Generate one Go package from both headers and map them to separate output files:
GoFileOf("a.h") == "a.go"
GoFileOf("b.h") == "b.go"
The forward declaration creates Point in a.go. The later definition fills
that type with c.Int and unsafe.Pointer fields.
Actual Result
a.go can be generated as:
package multifile
type Point struct {
X c.Int
Data unsafe.Pointer
}
but without the corresponding imports in a.go, resulting in undefined
identifiers. In larger bindings the same issue can instead appear as an alias
mismatch, for example an import of c with references to c1, or an import of
unsafe1 with references to unsafe.
Expected Result
The imports required by Point must be emitted in the same Go file as the
type declaration:
package multifile
import (
"github.com/goplus/lib/c"
"unsafe"
)
type Point struct {
X c.Int
Data unsafe.Pointer
}
Import aliases and all references must agree within every generated Go file,
regardless of header traversal order.
Environment
- llcppg current main branch
- LLGo toolchain
- C language mode
- Multiple generated Go files selected through
GoFileOf
- 主要言語
- Go
- スター
- 39
- フォーク
- 13
- 平均マージ
- 1時間 28分
- マージ済み PR(30日)
- 256
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
goplus/llcppg のほかの issue
-
bug
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
メンテナーはふだん 1 日以内に返信
-
feature proposal
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
Architecture-Design feature to be confirm
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
SAP/crossplane-provider-btp#1118 ·
メンテナーはふだん 1 日以内に返信
-
benchmark: `make setup` fails because audit-exporter builds with Go 1.25.0 while go.mod requires 1.26.0対応中かも @xsvm が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
volcano-sh/volcano#6097 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Bedrock invoke-with-response-stream reports `stop_reason: "end_turn"` for tool-use turnsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信