This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[libcpp] patch: add used callback
- From: Arnaud Charlet <charlet at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Mon, 16 Nov 2009 12:55:21 +0100
- Subject: [libcpp] patch: add used callback
Hi,
As discussed yesterday on the gcc list:
http://gcc.gnu.org/ml/gcc/2009-11/msg00407.html
Here is a submission for a new callback in libcpp that triggers each
time a macro is used (tested or expanded).
OK for mainline?
2009-11-16 Arnaud Charlet <charlet@adacore.com>
* macro.c (enter_macro_context): Call cb.used callback if defined.
* include/cpplib.h (struct cpp_callbacks): Add used callback.
--
Index: macro.c
===================================================================
--- macro.c (revision 153897)
+++ macro.c (working copy)
@@ -885,6 +885,9 @@ enter_macro_context (cpp_reader *pfile,
pfile->cb.used_define (pfile, pfile->directive_line, node);
}
+ if (pfile->cb.used)
+ pfile->cb.used (pfile, pfile->directive_line, node);
+
macro->used = 1;
if (macro->paramc == 0)
Index: include/cpplib.h
===================================================================
--- include/cpplib.h (revision 153897)
+++ include/cpplib.h (working copy)
@@ -508,6 +508,8 @@ struct cpp_callbacks
/* Called before #define and #undef or other macro definition
changes are processed. */
void (*before_define) (cpp_reader *);
+ /* Called whenever a macro is referenced (expanded or tested). */
+ void (*used) (cpp_reader *, unsigned int, cpp_hashnode *);
};
#ifdef VMS