fix(cl): defer incomplete enum declarations instead of querying an invalid underlying type
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #1145 de @MeteorsLiu — fusionado
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 75/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Go
- Estrellas
- 40
- Forks
- 13
- Merge medio
- 2 h 44 min
- PR fusionados (30 d)
- 112
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de goplus/llcppg
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
feature proposal
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
proposal
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
Todos los issues de goplus/llcppg
Issues similares
-
agent-butler-finding bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
jordansmall/spindrift#6414 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Icinga/icinga-kubernetes#294 ·
Los mantenedores suelen responder en 4 días
-
Cluster details: the Control Plane version field has a different border color than its icon boxAbiertokind/design sig/ui
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
kubermatic/dashboard#8449 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
filecoin-project/curio#1632 ·
Los mantenedores suelen responder en 1 día