[cfe-dev] Merging of translation units.

Douglas Gregor dgregor at apple.com
Tue Dec 13 10:06:22 PST 2011


On Dec 13, 2011, at 6:56 AM, Enea Zaffanella wrote:

> Hello.
> 
> 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?


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



More information about the cfe-dev mailing list