This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Interface for manipulating the abstract syntax tree
- From: Revital1 Eres <ERES at il dot ibm dot com>
- To: "Ferad Zyulkyarov" <feradz at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 5 Dec 2006 13:04:24 +0200
- Subject: Re: Interface for manipulating the abstract syntax tree
> I try to change the front-end tree structure of a c/c++ program as a
> side effect of execution of a pragma. The operations that are involved
> is to walk through in a tree (i.e "C" block), insertion of a tree
> (i.e. statement, block, declaration) in the abstract syntax tree and
> deletion of a tree (i.e. statement, block, declaration).
You can access the function's tree through it's call-graph node. (the
call-graph
node has a pointer to the function's tree declaration), than use
block_stmt_iterator (bsi) to iterate through the function's basic blocks;
each statement in the basic block can be recursively traversed via
walk_tree () function. (see cgraph_create_edges () in cgraphunit.c).
build1 () function (tree.h) can be used to construct a new tree node.
Hope it helps,
Revital