This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to find function_decl by identifier in plugin
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: Ivan Kulagin <kadet901 at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Mon, 26 Oct 2015 17:30:49 +0300
- Subject: Re: How to find function_decl by identifier in plugin
- Authentication-results: sourceware.org; auth=none
- References: <CANaLYJ_cQfebBfnB7PqDYFFu6cGCcW1Z0goKS+Z1tFRW0Vm80w at mail dot gmail dot com>
On 10/24/2015 02:31 PM, Ivan Kulagin wrote:
> Hello!
>
> I am writing some plugin and I have a problem with creating a function call.
> For creating call (by gimple_build_call) I have to specify the
> function_decl tree.
Does it work when GIMPLE representation is already built (just checking)?
> How can I get the list of all declarations (that used not only in
> current function, I need get the all available declarations also from
> included headers) in order to lookup by identifier function_decl which
> I want to call?
You probably need to use the symbol table. See the 'symbol_table' class
defined in 'cgraph.h' (there is a global instance of this class, 'symtab').
>
> For example:
> /* lookup_fn_decl - It is some pseudo-function which searches a
> function declaration by identifier */
There is a 'cgraph_node::get' static method.
> /* all_decl_list_head - It is pointer to the head list of all
> declarations. It is what I need */
Something like 'symtab->first_symbol ()' should work. There is also a
macro for walking all declared symbols, 'FOR_EACH_SYMBOL'.
--
Regards,
Mikhail Maltsev