fix(cl): defer incomplete enum declarations instead of querying an invalid underlying type
Maintainer thường phản hồi trong vòng 1 ngày
Một pull request liên quan đã được merge.
- #1145 của @MeteorsLiu — đã merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 75/100
Hướng nghiên cứu
Start with cl/enum.go, especially loadEnum and its call to newEnumType, then use the supplied rpc_enum.h reproduction and source/llcppg.cfg. Run GOOS=darwin GOARCH=arm64 llcppg ./generated ./source to reproduce the panic. Done means the incomplete declaration is deferred until its definition is available, the final integer type and constants are preserved, and an unavailable definition produces a clear error rather than a panic.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
An enum forward declaration causes a panic before a following complete definition can be processed. The libc survey first encountered this at enum clnt_stat in rpc/pmap_clnt.h.
Minimal reproduction
rpc_enum.h:
enum clnt_stat;
enum clnt_stat { RPC_SUCCESS = 0 };
Use a source Go module requiring github.com/goplus/lib v0.7.0, with this configuration in source/llcppg.cfg:
{
"Name": "libc",
"Language": "c",
"Dir": "$GOOS-$GOARCH/include",
"Files": [
"rpc_enum.h"
],
"FailFast": 0,
"IgnoreInline": true
}
Put the selected inputs under source/darwin-arm64/include, with the macOS 14.0 SDK headers available there where included. Leave Stdlib unset, and run:
GOOS=darwin GOARCH=arm64 llcppg ./generated ./source
Actual result
Generation exits 2 at the first line:
panic: rpc_enum.h:1:1: enum clnt_stat: unsupported underlying type (0: )
The 0 is CXType_Invalid for the incomplete enum's underlying type. In cl/enum.go, loadEnum calls newEnumType before checking decl.IsCursorDefinition(). The incomplete declaration is therefore materialized too early.
Expected behavior
An incomplete declaration accepted by the selected C parser should not be converted into a completed enum until its definition is available. Preserve the final definition's underlying integer type and constants. If a usable definition is unavailable, report that condition without panicking or inventing an integer type.
#1032 covers enum declarations nested in records and their registration/reuse. This reproduction is a top-level forward declaration followed by its definition, and fails earlier in newEnumType.
Environment
Reproduced on macOS/arm64 with LLVM/libclang 22.1.8, LLGo 1.0.9 and github.com/goplus/lib v0.7.0. The relevant installed generator sources were checked byte-for-byte against current main 90bd72cf. SDK-dependent cases use macOS 14.0 headers. These are generation-stage results, not cross-platform or ABI certification.
- Ngôn ngữ chính
- Go
- Star
- 40
- Fork
- 13
- Merge trung bình
- 2 giờ 48 phút
- Pull request đã merge (30 ngày)
- 109
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của goplus/llcppg
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 1 ngày
-
proposal
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 28/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
goplus/llcppg#1136 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của goplus/llcppg
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug raised-by:verifier
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
medici-finance/assay#5697 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sonatype-nexus-community/terraform-provider-sonatypeiq#101 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: metrics area: tracing contribfest enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
open-telemetry/opentelemetry-ebpf-instrumentation#4188 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
blinklabs-io/dingo#6074 ·
Maintainer thường phản hồi trong vòng 1 ngày