fix(cl): handle plain char on unsigned-char targets

Aperta
#1,150 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, go

Direzione di ricerca

Start with the C type mapping and macro argument generation implicated by the CXType_Char_U versus CXType_UChar distinction. Reproduce on Linux arm64 with the stated CI command, then compare generated output for cl/_testc/function and the cl/_testc/macrofn_auto/in.h fixture. Done means plain char bindings and forwarding macro string arguments generate successfully with behavior that respects target char signedness.

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

Descrizione

On Linux arm64, Clang reports plain C char as CXType_Char_U. llcppg currently maps Char_U and explicit unsigned char (CXType_UChar) together to Go uint8. This makes ordinary char * bindings incompatible with c.Str, which returns *c.Char.

Reproduction

On Linux arm64, run the existing CI command:

llgo test -v -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./...

The existing cl/_testc/macrofn_auto/in.h fixture contains this forwarding macro:

#define ZLIB_VERSION "1.3.1"
int deflateInit_(z_streamp strm, int level, const char *version, int stream_size);
#define z_deflateInit(strm, level) \
    deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))

Actual behavior

The const char *version parameter is mapped to *uint8, but the automatically generated macro call passes c.Str("1.3.1"), whose type is *c.Char. Generation panics because *c.Char cannot be passed as *uint8.

The generated output also differs from the existing fixtures for ordinary char * declarations. For example, cl/_testc/function produces Xprintf(fmt *uint8, ...) while the expected output uses *c.Char.

Expected behavior

Plain char bindings and string arguments in forwarding macros should work on Linux arm64 without a generation panic. Handling should account for the distinction between plain char and explicit unsigned char, as well as the target's char signedness.

Environment and evidence

Reproduced on Ubuntu 24.04 arm64 with LLVM 22, LLGo 1.0.8, Go 1.27.0, and github.com/goplus/lib v0.7.1, based on main commit b36e6307e67751c67654da37297ab654ef0ef0e3. The Linux arm64 job added in #1149 reproduces the failure: https://github.com/goplus/llcppg/actions/runs/42154256948/job/127684520612

Lingua principale
Go
Stelle
40
Fork
13
Merge medio
2h 44m
PR unite (30g)
112

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 goplus/llcppg

Tutte le issue di goplus/llcppg

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.