[cfe-dev] clang::Stmt, what's a child?

Chandler Carruth chandlerc at google.com
Wed Feb 23 22:09:47 PST 2011

On Wed, Feb 23, 2011 at 9:46 PM, Eric Niebler <eric at boostpro.com> wrote:

> OK, this seems like a stupid question, and maybe it is. What should be
> considered a "child" of an expression in the AST? Imagine a node that
> holds both a rewritten tree (that will be used for code-gen purposes) as
> well as the original AST as the user wrote it. (This is the
> PropertyAccessOperator node as suggested by John McCall.) Clearly, the
> rewritten node is a child. But is the original expression? What does is
> really mean to be a child?

I don't know about the specific case you're referring to, but in general, a
child of an expression is some other expression of which the parent is
composed. I think an example explains it best: "x + y" is an expression, the
binary operator "+". It contains two child expressions, "x" and "y".

I wouldn't expect the rewritten node and the original node to have any
parent / child relationship. That relationship should be reserved for nodes
that are part of the same tree structure. IE, what a consumer (say codegen)
would walk to get a "complete" view of the program, whether that view is
semantic or syntax oriented in nature.

Look at the relationship of a template specialization's AST nodes and the
template definition's AST nodes -- neither is the child of the other, but we
 create a separate connection between them so we can navigate from a
definition to all specializations and from a particular specialization back
to the definition.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110223/5cdd6e77/attachment.html>

More information about the cfe-dev mailing list