This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc macro collection


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]