[cfe-dev] libclang or libtooling for transpiler

Andrei Damian via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 28 10:57:41 PDT 2019


Hello. First time here, no tomatoes please.

Long story short, I want to attempt to make a cpp to rust transpiler. I
know it’s a very big task with a lot of work, but let’s ignore that for a
moment.

Like any sane person who doesn’t want to parse cpp himself (or any text
format for that matter), I’m counting on clang to be able to give me enough
information (the whole AST?) so that I’d be able to translate it.

>From what I can see my options are the following:

1. libtooling, which from what I understand can do „everything”, but is
somewhat unstable;

2. libclang, which is a C interface to the AST. So basically a stable C API
to libtooling.

I would just go with libtooling to be safe in a normal circumstance, but I
was really hoping that I could make the transpiler in rust, and using
libtooling in this case would be problematic as its API is CPP and I would
have to make bindings to rust for everything.

So, from what I can see, my options here are:

1.       libtooling + cpp, not ideal because I was hoping I would be able
to do it in rust;

2.       libclang + rust, would be great but I don’t know if it’ll be
enough;

3.       libclang + rust + extensions, so basically I’d extend the libclang
API myself (somehow?) where I would need it;

4.       libtooling + rust, hopefully not.

So, here’s the question(s): Will libclang suffice my need? Which option
would you consider is the best?

Thanks,

Andrei.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190428/c395b28e/attachment.html>


More information about the cfe-dev mailing list