Life of an instruction in LLVM

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Rock and a hard place

Clang is lovely and the LLVM IR is very well thought out. But for people that are interested in source-level manipulation the situation becomes very murky. If you want to maintain a mapping back to the tokens in the source / directly operate on the AST then there are two options:

1. Use the libclang interface that is designed to be a stable, externally visible interface.
2. Use the internal AST classes in C++ and link against parts of clang directly.

Unfortunately the first interface is very stable - it does not seem to change at all, and vast chunks of functionality and/or necessary details of the program are not exposed through CXCursors. The second interface does seem to change regularly enough for there to be be giant warnings all over the docs that it is not stable from version to version. Neither option seems appealing.

Has anyone come up with a third way for accessing the AST that clang produces in such a way that the details are not hidden behind opaque hidden members and it is stable across different versions?

I guess the third way would

I guess the third way would be to extend the libclang interface. I think the documentation even mentions this as a TODO.