From b4e46cea24515316b941bfacae8417c078fc5701 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 20 Mar 2003 16:46:18 +0000 Subject: [PATCH] Various cleanups to help compile server. * cppinit.c (cpp_create_reader): Take extra hash_table* argument, and pass that to _cpp_init_hashtable. (cpp_read_main_file): Drop hash_table* argument; don't call _cpp_init_hashtable. * cpplib.h: Update declarations to match. * c-opts.c (c_common_init_options): Pass ident_hash to cpp_create_reader. (c_common_post_options): Don't pass ident_hash to cpp_read_main_file. * fix-header.c (read_scan_file): Likewise pass NULL table to cpp_create_reader rather than cpp_read_main_file. * cppfiles.c (cpp_rename_file): Generalized and renamed to cpp_change_file. * cpplib.h: Update declaration to match. * c-opts.c (push_command_line_line, finish_options): Change cpp_rename_file calls to cpp_change_file. From-SVN: r64617 --- gcc/ChangeLog | 17 +++++++++++++++++ gcc/c-opts.c | 11 ++++++----- gcc/cppfiles.c | 10 ++++++---- gcc/cppinit.c | 13 +++++-------- gcc/cpplib.h | 22 +++++++++++----------- gcc/fix-header.c | 8 ++++---- 6 files changed, 49 insertions(+), 32 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe92cf9c872..b79f2bd6b54 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -2,6 +2,23 @@ Various cleanups to help compile server. + * cppinit.c (cpp_create_reader): Take extra hash_table* argument, + and pass that to _cpp_init_hashtable. + (cpp_read_main_file): Drop hash_table* argument; don't call + _cpp_init_hashtable. + * cpplib.h: Update declarations to match. + * c-opts.c (c_common_init_options): Pass ident_hash to + cpp_create_reader. + (c_common_post_options): Don't pass ident_hash to cpp_read_main_file. + * fix-header.c (read_scan_file): Likewise pass NULL table to + cpp_create_reader rather than cpp_read_main_file. + + * cppfiles.c (cpp_rename_file): Generalized and renamed + to cpp_change_file. + * cpplib.h: Update declaration to match. + * c-opts.c (push_command_line_line, finish_options): Change + cpp_rename_file calls to cpp_change_file. + * line-map.c (add_line_map): Allow leaving the outermost file. Allowing entering an outermost-file after the initial time. diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 8c639cca293..5de5019499b 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -587,7 +587,8 @@ c_common_init_options (lang) #endif c_language = lang; - parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX); + parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX, + ident_hash); cpp_opts = cpp_get_options (parse_in); if (flag_objc) cpp_opts->objc = 1; @@ -1569,7 +1570,7 @@ c_common_post_options (pfilename) cpp_get_callbacks (parse_in)->file_change = cb_file_change; /* NOTE: we use in_fname here, not the one supplied. */ - *pfilename = cpp_read_main_file (parse_in, in_fname, ident_hash); + *pfilename = cpp_read_main_file (parse_in, in_fname); saved_lineno = lineno; lineno = 0; @@ -1784,10 +1785,10 @@ finish_options () { size_t i; - cpp_rename_file (parse_in, _("")); + cpp_change_file (parse_in, LC_RENAME, _("")); cpp_init_builtins (parse_in); c_cpp_builtins (parse_in); - cpp_rename_file (parse_in, _("")); + cpp_change_file (parse_in, LC_RENAME, _("")); for (i = 0; i < deferred_count; i++) { struct deferred_opt *opt = &deferred_opts[i]; @@ -1837,7 +1838,7 @@ push_command_line_include () if (include_cursor == deferred_count) { /* Restore the line map from . */ - cpp_rename_file (parse_in, main_input_filename); + cpp_change_file (parse_in, LC_RENAME, main_input_filename); /* -Wunused-macros should only warn about macros defined hereafter. */ cpp_opts->warn_unused_macros = warn_unused_macros; include_cursor++; diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 9bcdb9edb5d..1ff34ff0084 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -756,14 +756,16 @@ cpp_make_system_header (pfile, syshdr, externc) SOURCE_LINE (pfile->map, pfile->line), flags); } -/* Allow the client to rename the current file. Used by the front end - to achieve pseudo-file names like . */ +/* Allow the client to change the current file. Used by the front end + to achieve pseudo-file names like . + If REASON is LC_LEAVE, then NEW_NAME must be NULL. */ void -cpp_rename_file (pfile, new_name) +cpp_change_file (pfile, reason, new_name) cpp_reader *pfile; + enum lc_reason reason; const char *new_name; { - _cpp_do_file_change (pfile, LC_RENAME, new_name, 1, 0); + _cpp_do_file_change (pfile, reason, new_name, 1, 0); } /* Report on all files that might benefit from a multiple include guard. diff --git a/gcc/cppinit.c b/gcc/cppinit.c index abfcc50eadc..376d72e9e58 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -132,8 +132,9 @@ init_library () /* Initialize a cpp_reader structure. */ cpp_reader * -cpp_create_reader (lang) +cpp_create_reader (lang, table) enum c_lang lang; + hash_table *table; { cpp_reader *pfile; @@ -199,6 +200,8 @@ cpp_create_reader (lang) _cpp_init_includes (pfile); + _cpp_init_hashtable (pfile, table); + return pfile; } @@ -429,20 +432,14 @@ cpp_add_dependency_target (pfile, target, quote) or stdin if it is the empty string. Return the original filename on success (e.g. foo.i->foo.c), or NULL on failure. */ const char * -cpp_read_main_file (pfile, fname, table) +cpp_read_main_file (pfile, fname) cpp_reader *pfile; const char *fname; - hash_table *table; { sanity_checks (pfile); post_options (pfile); - /* The front ends don't set up the hash table until they have - finished processing the command line options, so initializing the - hashtable is deferred until now. */ - _cpp_init_hashtable (pfile, table); - /* Mark named operators before handling command line macros. */ if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names)) mark_named_operators (pfile); diff --git a/gcc/cpplib.h b/gcc/cpplib.h index edd521b041e..ec5f8e47c1e 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -485,8 +485,13 @@ struct cpp_hashnode GTY(()) } GTY ((desc ("0"))) value; }; -/* Call this first to get a handle to pass to other functions. */ -extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang)); +/* Call this first to get a handle to pass to other functions. + + If you want cpplib to manage its own hashtable, pass in a NULL + pointer. Otherwise you should pass in an initialized hash table + that cpplib will share; this technique is used by the C front + ends. */ +extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang, struct ht *)); /* Call this to change the selected language standard (e.g. because of command line options). */ @@ -518,14 +523,8 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *)); returns the name of the original file; this is the same as the input file, except for preprocessed input. This will generate at least one file change callback, and possibly a line change callback - too. If there was an error opening the file, it returns NULL. - - If you want cpplib to manage its own hashtable, pass in a NULL - pointer. Otherwise you should pass in an initialized hash table - that cpplib will share; this technique is used by the C front - ends. */ -extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *, - struct ht *)); + too. If there was an error opening the file, it returns NULL. */ +extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *)); /* Set up built-ins like __FILE__. */ extern void cpp_init_builtins PARAMS ((cpp_reader *)); @@ -708,7 +707,8 @@ extern int cpp_included PARAMS ((cpp_reader *, const char *)); extern void cpp_make_system_header PARAMS ((cpp_reader *, int, int)); extern void cpp_simplify_path PARAMS ((char *)); extern bool cpp_push_include PARAMS ((cpp_reader *, const char *)); -extern void cpp_rename_file PARAMS ((cpp_reader *, const char *)); +extern void cpp_change_file PARAMS ((cpp_reader *, enum lc_reason, + const char *)); /* In cpppch.c */ struct save_macro_data; diff --git a/gcc/fix-header.c b/gcc/fix-header.c index 8434ccee657..423cd57fb8f 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -622,7 +622,7 @@ read_scan_file (in_fname, argc, argv) obstack_init (&scan_file_obstack); - scan_in = cpp_create_reader (CLK_GNUC89); + scan_in = cpp_create_reader (CLK_GNUC89, NULL); cb = cpp_get_callbacks (scan_in); cb->file_change = cb_file_change; @@ -632,7 +632,7 @@ read_scan_file (in_fname, argc, argv) options->inhibit_warnings = 1; options->inhibit_errors = 1; - if (! cpp_read_main_file (scan_in, in_fname, NULL)) + if (! cpp_read_main_file (scan_in, in_fname)) exit (FATAL_EXIT_CODE); for (i = 0; i < argc; i += strings_processed) @@ -675,9 +675,9 @@ read_scan_file (in_fname, argc, argv) true /* stdinc */, false /* cxx_stdinc */, false /* verbose */); - cpp_rename_file (scan_in, ""); + cpp_change_file (scan_in, LC_RENAME, ""); cpp_init_builtins (scan_in); - cpp_rename_file (scan_in, in_fname); + cpp_change_file (scan_in, LC_RENAME, in_fname); /* We are scanning a system header, so mark it as such. */ cpp_make_system_header (scan_in, 1, 0);