From b826515a45a10ae7ee9c0979f7093694669bb034 Mon Sep 17 00:00:00 2001 From: Basile Starynkevitch Date: Tue, 19 Nov 2013 16:26:52 +0000 Subject: [PATCH] c-opts.c: Include plugin.h. [gcc/c-family] 2013-11-19 Basile Starynkevitch * c-opts.c: Include plugin.h. (cb_file_change): Invoke plugin event PLUGIN_INCLUDE_FILE. [gcc/] 2013-11-19 Basile Starynkevitch * plugin.def (PLUGIN_INCLUDE_FILE): New event, invoked in cb_file_change. From-SVN: r205038 --- gcc/ChangeLog | 5 +++++ gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-opts.c | 12 ++++++++++++ gcc/plugin.def | 6 ++++++ 4 files changed, 28 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b2d761aba91..d76c2a30268 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-11-19 Basile Starynkevitch + + * plugin.def (PLUGIN_INCLUDE_FILE): New event, invoked in + cb_file_change. + 2013-11-19 Peter Bergner * loop-doloop.c (doloop_optimize_loops): Remove unused diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 599c024c9b0..5bbd5f5c5ef 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2013-11-19 Basile Starynkevitch + + * c-opts.c: Include plugin.h. + (cb_file_change): Invoke plugin event PLUGIN_INCLUDE_FILE. + 2013-11-19 Marek Polacek * c-ubsan.c (ubsan_instrument_division): Adjust ubsan_create_data diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 34fe94de34b..f368cab289f 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see #include "debug.h" /* For debug_hooks. */ #include "opts.h" #include "options.h" +#include "plugin.h" /* For PLUGIN_INCLUDE_FILE event. */ #include "mkdeps.h" #include "c-target.h" #include "tm.h" /* For BYTES_BIG_ENDIAN, @@ -1397,6 +1398,17 @@ cb_file_change (cpp_reader * ARG_UNUSED (pfile), else fe_file_change (new_map); + if (new_map + && (new_map->reason == LC_ENTER || new_map->reason == LC_RENAME)) + { + /* Signal to plugins that a file is included. This could happen + several times with the same file path, e.g. because of + several '#include' or '#line' directives... */ + invoke_plugin_callbacks + (PLUGIN_INCLUDE_FILE, + const_cast (ORDINARY_MAP_FILE_NAME (new_map))); + } + if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P (new_map))) { pch_cpp_save_state (); diff --git a/gcc/plugin.def b/gcc/plugin.def index c4ca61be14a..25a645854a7 100644 --- a/gcc/plugin.def +++ b/gcc/plugin.def @@ -92,6 +92,12 @@ DEFEVENT (PLUGIN_EARLY_GIMPLE_PASSES_END) /* Called when a pass is first instantiated. */ DEFEVENT (PLUGIN_NEW_PASS) +/* Called when a file is #include-d or given thru #line directive. + Could happen many times. The event data is the included file path, + as a const char* pointer. */ +DEFEVENT (PLUGIN_INCLUDE_FILE) + + /* After the hard-coded events above, plugins can dynamically allocate events at run time. PLUGIN_EVENT_FIRST_DYNAMIC only appears as last enum element. */ -- 2.30.2