Guidance for AI coding agents and new contributors working in the llcppg repository.
llcppg (LLGo autogen tool) automatically generates LLGo bindings for C/C++ libraries, enhancing the experience of integrating LLGo with C/C++. It parses C/C++ headers via libclang and emits Go source that maps the library's public API onto LLGo.
- Module:
github.com/goplus/llcppg - Language: Go
- Build/test toolchain: LLGo with LLVM/Clang
(llcppg depends on libclang and is compiled/tested with
llgo, not plaingo).
| Path | Description |
|---|---|
cl/ |
Core compiler: loads clang translation units and generates the Go package. |
cl/_testc/, cl/_testcpp/, cl/_testpp/ |
Fixture inputs (C, C++, and package tests) consumed by cl tests. Directories are _-prefixed so the Go toolchain ignores them as packages. |
clang/ |
Higher-level clang helpers. |
lib/clang/ |
Low-level libclang bindings generated by llcppg. |
cmd/llcppg/ |
Main llcppg command-line entry point. |
.github/ |
CI workflow (workflows/llgo.yml) and the setup-llgo composite action. |
Refer to the GitHub Action to download and build llgo (see .github/actions/setup-llgo).
Once llgo is installed and on PATH, run the same command as CI:
llgo test -v ./...Only the cl package has tests; it drives every fixture under cl/_testc
(C, via TestC), cl/_testcpp (C++, via TestCpp), and cl/_testpp
(TestPreprocessor). To iterate on one fixture, filter by name:
llgo test -v -run 'TestC/union_struct' ./cl/Each fixture directory has an input header (in.h) and a golden out.go. The
cl test harness (cl/compile_test.go) parses in.h with libclang, generates
Go, and diffs it against out.go. When adding or changing a fixture:
- Implement the generator change, then run the fixture test.
- When the generated Go differs from the golden (including a missing or stale
out.go), the harness writes the actual output toout.go.txt(gitignored via the*.txtrule) and fails the test — it does not silently accept a mismatch. Do not hand-write or hand-editout.go; always let the harness produce it so the golden matches the generator byte-for-byte. - Inspect
out.go.txt, and once correct promote it:mv out.go.txt out.go. - Re-run until the fixture passes with no
out.go.txtproduced.
Make the tests pass before submitting a change.
- Format:
feat(pkg): xxx,fix(pkg): xxx, orProposal: xxx. pkgis the package(s) affected by the issue. Multiple packages are separated by,, e.g.fix(cl,parser): xxx.Proposal: xxxissues usually affect theclpackage, so they are equivalent tofeat(cl): xxx.