[cfe-dev] AST generation API?

Douglas Gregor dgregor at apple.com
Tue Mar 20 14:54:05 PDT 2012


On Mar 20, 2012, at 11:26 AM, Dave Abrahams wrote:

> 
> Is there a component/API in Clang, separate from the parser, for
> generating valid ASTs?

If you are *extremely* careful, you can create ASTs directly with the AST library, but there isn't much to help you get it right. To actually build semantically valid ASTs (including introducing implicit conversions and such), you would need to call into Sema's entry points yourself.

>  If not, has anyone given thought to what
> that might look like?


Not really. One could certainly imagine creating a set of wrapper classes that allow one to form AST nodes using expression syntax, so that you write simple C++ expressions that evaluate into the appropriate Sema calls. I'm sure that people wanting to do AST manipulations would love to have such a library.

	- Doug



More information about the cfe-dev mailing list