[ANN] clangml 4.2.0: OCaml bindings for Clang API (for C and C++ parsing)

Side question - are there any plans to release tools/stubgen as separate toplevel tool to generate bindings to arbitrary C/C++ libraries? There is relevant work in ctypes_of_clang but the project seems abandoned unfortunately.

There are plans… but things are going too much slowly. I think @Armael wrote previously in this thread a good summary of what a generator could be, but I did not manage to take time for implementing something in these lines. stubgen is very ad-hoc, and has complex strategies relative to memory management and callbacks: it will definitively be interesting to generalize these transformations, but it will take time.

Thank you again! I quickly tested the new snapshot and it works great.

If I may add another feature request, I’d be interested in some way to handle the UnexposedType TypeOf and UnexposedType TypeOfExpr constructors (these correspond to the typeof keyword Typeof (Using the GNU Compiler Collection (GCC))).
I could not find a way to retrieve the argument since with types there is no corresponding cursor (I think) from which I could access the children of the ast node.

Fixed in snapshot! Thank you for reporting this as well.

clangml.4.7.0 is now in opam, with the bug fixes/features requested by @n47 and some others. All LLVM/Clang versions up to 14.0.x are supported, as well as OCaml 5.0. The official repo is now on github: GitHub - thierry-martinez/clangml which should ease posting issues and pull requests (and should be more convenient than discussions on this thread!).

Support for the upcoming Clang 15 is planned for the next release that should happen soon (the development version already supports Clang 15).

4 Likes