Merging of translation units.


We would like to know what kind of support is already available in clang
(or it is planned to be available in the near future) concerning the
goal described below.

In rough words, we would like to "logically merge" the ASTs resulting
from the parsing of many translation units so as to be able to query
their information as if they were coming from a single, well-formed AST.

The physical representation of the "logically merged" AST would be based
on the component translation units, but avoiding the duplications caused
by common inclusions so that the merged AST satisfies, at least, the
common ODR constraints. Also, we would like to be able to obtain
canonical versions of the declarations introduced/referenced across the
many component TUs.

Is there anything similar implemented in clang (or publicly available in
a separate project based on clang)? Are there implemented services that,
even though not a solution, could be used as a good starting point?

Thanks in advance for any useful info.


ASTImporter is essentially designed to do this, and is there to support LLDB, which also merges multiple translation units (each with its own ASTContext) into a single ASTContext.

Note that this is an *extremely* hard problem to solve correctly, and ASTImporter is only part of the way there. However, I think it could grow toward a decent solution.

  - Doug