This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: gcc macro collection
- From: Yunfeng ZHANG <zyf dot zeroos at gmail dot com>
- To: Dodji Seketeli <dodji at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, "Joseph S. Myers" <joseph at codesourcery dot com>, Dave Korn <dave dot korn dot cygwin at googlemail dot com>, Tom Tromey <tromey at redhat dot com>
- Date: Wed, 2 Jun 2010 16:36:10 +0800
- Subject: Re: gcc macro collection
- References: <AANLkTimll4Kw76pg6f_DERxRBvBBc-1kKz8FmHW2bUdh@mail.gmail.com> <m3aark1ain.fsf@redhat.com> <AANLkTimMzqFExQ3XhoIe8rwm9BewjISMdK26sRBEpzpk@mail.gmail.com>
To Dodji Seketeli
My patch is originally designed as symbol collection plugin, so it
concentrates on macro/macro-replacement tokens which are visible to final user
in .c and .i file. Goto section <New symdb Token Type> of my symdb.txt. The
process is
*) ... catch tokens from PLUGIN_CPP_TOKEN event ...
*) macro_start_expand notifies you macro expansion has occured.
*) 1-level macro tokens are catched by directive_token callback.
*) using PLUGIN_CPP_TOKEN event to continue to collect macro-replacement
tokens (1-level macro-replacement).
*) macro_start_expand notifies 2-level expansion has occured.
*) 2-level macro tokens are catched by macro_intern_expand callback. In
the callback, you use data stored in pfile->context directly.
*) 2-level macro-replacement tokens can be catched still by PLUGIN_CPP_TOKEN
event.
*) macro_end_expand.
*) 1-level macro-replacement tokens if exist (PLUGIN_CPP_TOKEN).
*) macro_end_expand.
As I've said, I don't care about tokens which is invisible to user (such as in
replace_args, so maybe can't help your patch), and currently I don't record
where macro-declaration is, of course I can (add new fields -- file_name and
file_offset to cpp_macro).
By the way I think macro_intern_expand is appropriate,
between funlike_invocation_p and replace_args in enter_macro_context, so it
gives the boundary between macro and macro-replacement.
Yunfeng