From 438ac94c9b141e04a7b2512298120f5724b521ed Mon Sep 17 00:00:00 2001 From: neil Date: Tue, 21 Aug 2001 21:17:48 +0000 Subject: [PATCH] * cppfiles.c (stack_include_file): Don't handle -H here. * cppinit.c (cpp_start_read): Set include tracing after cpp_post_options and after stacking the main file. * line-map.c (trace_include): New. (init_line_maps, add_line_map): Update. * line-map.h (struct line_maps): New member trace_includes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45084 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 9 +++++++++ gcc/cppfiles.c | 14 ++------------ gcc/cppinit.c | 5 +++++ gcc/line-map.c | 23 ++++++++++++++++++++++- gcc/line-map.h | 3 +++ 5 files changed, 41 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 58889c7f2b0..04b2d0c5850 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,14 @@ 2001-08-21 Neil Booth + * cppfiles.c (stack_include_file): Don't handle -H here. + * cppinit.c (cpp_start_read): Set include tracing after + cpp_post_options and after stacking the main file. + * line-map.c (trace_include): New. + (init_line_maps, add_line_map): Update. + * line-map.h (struct line_maps): New member trace_includes. + +2001-08-21 Neil Booth + * cppfiles.c (stack_include_file): Harmonize system headerness tests. * cppfiles.c (stack_include_file): Only stack a file if there is something to do. Return a boolean indicating whether a diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index da244beb25d..1d60d367257 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -313,18 +313,8 @@ stack_include_file (pfile, inc) } if (pfile->buffer) - { - /* We don't want MI guard advice for the main file. */ - inc->include_count++; - - /* Handle -H option. */ - if (CPP_OPTION (pfile, print_include_names)) - { - for (fp = pfile->buffer; fp; fp = fp->prev) - putc ('.', stderr); - fprintf (stderr, " %s\n", inc->name); - } - } + /* We don't want MI guard advice for the main file. */ + inc->include_count++; /* Push a buffer. */ fp = cpp_push_buffer (pfile, inc->buffer, inc->st.st_size, BUF_FILE, 0); diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 0c4aa01da97..b57910cb3e6 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -939,6 +939,11 @@ cpp_start_read (pfile, fname) if (!_cpp_read_file (pfile, fname)) return 0; + /* Set this after cpp_post_options so the client can change the + option if it wishes, and after stacking the main file so we don't + trace the main file. */ + pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names); + /* Install builtins and process command line macros etc. in the order they appeared, but only if not already preprocessed. */ if (! CPP_OPTION (pfile, preprocessed)) diff --git a/gcc/line-map.c b/gcc/line-map.c index d1df5572b83..b2809b1510c 100644 --- a/gcc/line-map.c +++ b/gcc/line-map.c @@ -25,6 +25,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "line-map.h" #include "intl.h" +static void trace_include + PARAMS ((const struct line_maps *, const struct line_map *)); + /* Initialize a line map set. */ void @@ -35,6 +38,7 @@ init_line_maps (set) set->allocated = 0; set->used = 0; set->last_listed = -1; + set->trace_includes = false; } /* Free a line map set. */ @@ -136,8 +140,11 @@ add_line_map (set, reason, sysp, from_line, to_file, to_line) map->included_from = map[-1].included_from; else if (reason == LC_LEAVE) map->included_from = INCLUDED_FROM (set, map - 1)->included_from; - set->used++; + + if (reason == LC_ENTER && set->trace_includes) + trace_include (set, map); + return map; } @@ -207,3 +214,17 @@ print_containing_files (set, map) fputs (":\n", stderr); } + +/* Print an include trace, for e.g. the -H option of the preprocessor. */ + +static void +trace_include (set, map) + const struct line_maps *set; + const struct line_map *map; +{ + const struct line_map *m; + + for (m = map; !MAIN_FILE_P (m); m = INCLUDED_FROM (set, m)) + putc ('.', stderr); + fprintf (stderr, " %s\n", map->to_file); +} diff --git a/gcc/line-map.h b/gcc/line-map.h index ed02420e112..a226a1fdfc2 100644 --- a/gcc/line-map.h +++ b/gcc/line-map.h @@ -59,6 +59,9 @@ struct line_maps LAST_LISTED as the topmost including file. -1 indicates nothing has been listed yet. */ int last_listed; + + /* If true, prints an include trace a la -H. */ + bool trace_includes; }; /* Initialize a line map set. */ -- 2.11.4.GIT