How flexible is the AST of Clang and its file format?

Hi Clang list,

I've been on the LLVM Dev list for a while now and was getting frustrated with
trying to make a cross-platform bitcode distribution when I noticed there is an
AST file format used for higher-level representations of C-like languages under
Clang.

What I want to do is make a GUI that represents the parse tree of a high-level
language as a tree-browser gadget so that it can be edited just like the code
but without the parsing and the keywords. I know it's been done before but I
think it will be a good exercise in programming.

Is it possible? Moreso, is it practical? I'd like to kind of cherry-pick the
capabilities I support, eg. no preprocessor but yes templates.

Thanks for your patience and your thoughts,

--Sam Crow

Clang's AST file format specifically encodes the Clang AST and all of its bits, so the file format changes as we evolve Clang's internal AST. It's fine for an intermediate format, but I strongly advise against using it as the file format for a GUI tool.

I'd love to see some kind of tree-browsing gadget. I think it's be really useful for understanding you program. Direct AST manipulations will be rather tricky, since the Clang AST is designed to be immutable once created, but you can extend an AST and probably perform some manipulations safely (e.g., replacing a function body with a new function body).

  - Doug