Re: Interface for manipulating the abstract syntax tree

2006-12-07 Thread Ferad Zyulkyarov
Hi again, Yes. You can start by calling it in the same place cgraph_create_edges () is been called. (cgraph_analyze_function ()) To be able to do that, probably I will need to register a new token (i.e. MY_PRAGMA_TOKEN) and build a node of this token within the pragma handler (in c-pragma.c).

Re: Interface for manipulating the abstract syntax tree

2006-12-07 Thread Revital1 Eres
> > And the code crashes at the macro FOR_EACH_BB_FN.. This is exatly as > it is implemented in cgraph_create_edges() function.. but I think that > the problem is because I call it at wrong time (too early, or too late > - before or after parsing).. Could it be? Yes. You can start by calling it

Re: Interface for manipulating the abstract syntax tree

2006-12-07 Thread Ferad Zyulkyarov
Hi Revital, Because of doing copy, paste I forgot to delete one line from the CASE 1 example: Instead: > /* below I pass a the tree of the current_function_decl a global > variable in tree.h */ > this_cfun = DECL_STRUCT_FUNCTION(current_function_decl); > FOR_EACH_BB_FN(bb, this_cfu

Re: Interface for manipulating the abstract syntax tree

2006-12-07 Thread Revital1 Eres
> /* below I pass a the tree of the current_function_decl a global > variable in tree.h */ > this_cfun = DECL_STRUCT_FUNCTION(current_function_decl); > FOR_EACH_BB_FN(bb, this_cfun) /* Crashes here, Also tried with > FOR_EACH_BB */ > for (bsi = bsi_start(bb); !bsi_end_p(bsi); b

Re: Interface for manipulating the abstract syntax tree

2006-12-06 Thread Ferad Zyulkyarov
Hi, In file "c-pragma.c" I try to implement my custom pragma handler where I try to traverse the statements within the function where the pragma is detected. To implement the traversal I used the implementation of "cgraph_create_edges" function as reference (in cgraphunit.c file). My code is as

Re: Interface for manipulating the abstract syntax tree

2006-12-05 Thread Mike Stump
On Dec 5, 2006, at 3:14 AM, Ferad Zyulkyarov wrote: Also, having the opportunity, I would like to ask you if there is any function to use for deleting a tree ggc_free if you _know_ it is free.

Re: Interface for manipulating the abstract syntax tree

2006-12-05 Thread Andrew Haley
Ferad Zyulkyarov writes: > > Also, having the opportunity, I would like to ask you if there is any > function to use for deleting a tree (most particularly a statement or > variable declaration tree) or it would be enough to assign it as NULL > (which does not seems to be a gentle solution).

Re: Interface for manipulating the abstract syntax tree

2006-12-05 Thread Ferad Zyulkyarov
Hi Revital, Thank you very much.. This is very helpful. I was about to lost myself in the code. I will try to experiment with your advices. Also, having the opportunity, I would like to ask you if there is any function to use for deleting a tree (most particularly a statement or variable declara

Re: Interface for manipulating the abstract syntax tree

2006-12-05 Thread Revital1 Eres
> 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