Well, there are currently multiple use cases in clang: pch files
(precompiled headers), pcm files (modules), and I think arcmigrate uses
ASTUnit (but I don't know the details).
though does make sense to tell to the compiler to say generate pch from a
C++ file as it does not make sense, it makes sense to generate AST, which
is possible, but.. still... it is impossible to load AST, regardless of the
size. Any usecase I was thinking about would hold the AST temporary, so
would not be an issue. Did some test and in avarage ast files are bit more
than double larger as an object file with debug information.
The problem is that when you store the AST for a full TU, it's *huge* (all
the transitive headers are in it) and I'm not sure why you would want to do
Well, from a TU point of view it makes sense to have the header
information. When you analyze or (do code completion, I assume), you need
the full bagage. Though having symbols that are not required by the cpp
file is overhead. Is there any feature to say: discard unreferenced symbols
(types, globals etc.). Still not sure how code completion works and how
adding new symbols added to the code are updated (if at all) in the AST.
If you think tools are too slow, then our proposed solution for that is
using C++ modules (which will also dump the AST, but in a much more nuanced
and smart fashion).
well, did some research if it would be possible to build llvm and clang
with C++ modules. No luck? Any hints?
That's why the use case matters; if you're interested in processing speed,
the solution is modules (and the way it serializes the AST).
happy with that... would be happy to see llvm/clang built with modules. I
am sure one could find all info in module based AST's that can be found in
If your use case is something else, the answer might be something
so far I can do my job, I found enough examples in libclang to load from
AST, just was wondering what is the point to dump AST with clang without
being able to explicitly load it in most of the tools.