This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
how to iterate the local variables of a function in a plugin
- From: weixing ji <bitjwx at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 8 Apr 2011 12:31:02 +0800
- Subject: how to iterate the local variables of a function in a plugin
hi,
I am writing a plugin which is invoked at the event
"PLUGIN_OVERRIDE_GATE". My question is how to access all the local
variables of a function if I get a FUNC_DECL tree node. I have tried
as following:
for(block = DECL_INITIAL(fn_decl); block; block = TREE_CHAIN(block))
{
for (temp = BLOCK_VARS (block); temp; temp = TREE_CHAIN (temp))
{
cerr << tree_code_name[TREE_CODE(temp)] << ;
}
}
But this code does not work and it results in a segment fault. Could
someone tell me how to do that?
Thanks for taking your time.
Ji