[cfe-dev] Delay Clang CodeGen until AST is fully populated

Alexandre Isoard via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 1 15:52:31 PDT 2019

We are really struggling with separating Sema and CodeGen.

Here are the few dead-end we hit:

1) We tried to use -emit-ast to get a PCH-like AST, but it seems it does
not do template specialization.
That is, when we feed it again into clang, some of the Sema is still run
after CodeGen.
We stopped there, because we are not sure this can help us.

2) We tried -traditional-cpp and -no-integrated-cpp which is supposed to
forbid clang driver to merge the different stages (it didn't help). I do
not know if this was effective, but we didn't see any difference. So maybe
it is the same issue as the previous one? We also stopped there, because we
use clang -cc1 anyway.

3) We started looking into ASTConsumer(s) and we are thinking if it is
possible to write an ASTConsumer that "forward" the AST to the CodeGen and
only implement the HandleTranslationUnit so that it ensure it receive the
entire AST before forwarding it. But I guess we need to explore it then run
manually each of the CodeGen method? Will it have the same issue about
template instantiation?

We would really appreciate if anybody could shed some light, we don't know
that part of the infrastructure.
Are we even going into the right direction? Is there already an option that
does that?

*Alexandre Isoard*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190701/d540bb84/attachment.html>

More information about the cfe-dev mailing list