Commit b4e46cea by Per Bothner Committed by Per Bothner

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
parent 8826ff0f
...@@ -2,6 +2,23 @@ ...@@ -2,6 +2,23 @@
Various cleanups to help compile server. 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. * line-map.c (add_line_map): Allow leaving the outermost file.
Allowing entering an outermost-file after the initial time. Allowing entering an outermost-file after the initial time.
......
...@@ -587,7 +587,8 @@ c_common_init_options (lang) ...@@ -587,7 +587,8 @@ c_common_init_options (lang)
#endif #endif
c_language = lang; 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); cpp_opts = cpp_get_options (parse_in);
if (flag_objc) if (flag_objc)
cpp_opts->objc = 1; cpp_opts->objc = 1;
...@@ -1569,7 +1570,7 @@ c_common_post_options (pfilename) ...@@ -1569,7 +1570,7 @@ c_common_post_options (pfilename)
cpp_get_callbacks (parse_in)->file_change = cb_file_change; cpp_get_callbacks (parse_in)->file_change = cb_file_change;
/* NOTE: we use in_fname here, not the one supplied. */ /* 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; saved_lineno = lineno;
lineno = 0; lineno = 0;
...@@ -1784,10 +1785,10 @@ finish_options () ...@@ -1784,10 +1785,10 @@ finish_options ()
{ {
size_t i; size_t i;
cpp_rename_file (parse_in, _("<built-in>")); cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
cpp_init_builtins (parse_in); cpp_init_builtins (parse_in);
c_cpp_builtins (parse_in); c_cpp_builtins (parse_in);
cpp_rename_file (parse_in, _("<command line>")); cpp_change_file (parse_in, LC_RENAME, _("<command line>"));
for (i = 0; i < deferred_count; i++) for (i = 0; i < deferred_count; i++)
{ {
struct deferred_opt *opt = &deferred_opts[i]; struct deferred_opt *opt = &deferred_opts[i];
...@@ -1837,7 +1838,7 @@ push_command_line_include () ...@@ -1837,7 +1838,7 @@ push_command_line_include ()
if (include_cursor == deferred_count) if (include_cursor == deferred_count)
{ {
/* Restore the line map from <command line>. */ /* Restore the line map from <command line>. */
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. */ /* -Wunused-macros should only warn about macros defined hereafter. */
cpp_opts->warn_unused_macros = warn_unused_macros; cpp_opts->warn_unused_macros = warn_unused_macros;
include_cursor++; include_cursor++;
......
...@@ -756,14 +756,16 @@ cpp_make_system_header (pfile, syshdr, externc) ...@@ -756,14 +756,16 @@ cpp_make_system_header (pfile, syshdr, externc)
SOURCE_LINE (pfile->map, pfile->line), flags); SOURCE_LINE (pfile->map, pfile->line), flags);
} }
/* Allow the client to rename the current file. Used by the front end /* Allow the client to change the current file. Used by the front end
to achieve pseudo-file names like <built-in>. */ to achieve pseudo-file names like <built-in>.
If REASON is LC_LEAVE, then NEW_NAME must be NULL. */
void void
cpp_rename_file (pfile, new_name) cpp_change_file (pfile, reason, new_name)
cpp_reader *pfile; cpp_reader *pfile;
enum lc_reason reason;
const char *new_name; 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. /* Report on all files that might benefit from a multiple include guard.
......
...@@ -132,8 +132,9 @@ init_library () ...@@ -132,8 +132,9 @@ init_library ()
/* Initialize a cpp_reader structure. */ /* Initialize a cpp_reader structure. */
cpp_reader * cpp_reader *
cpp_create_reader (lang) cpp_create_reader (lang, table)
enum c_lang lang; enum c_lang lang;
hash_table *table;
{ {
cpp_reader *pfile; cpp_reader *pfile;
...@@ -199,6 +200,8 @@ cpp_create_reader (lang) ...@@ -199,6 +200,8 @@ cpp_create_reader (lang)
_cpp_init_includes (pfile); _cpp_init_includes (pfile);
_cpp_init_hashtable (pfile, table);
return pfile; return pfile;
} }
...@@ -429,20 +432,14 @@ cpp_add_dependency_target (pfile, target, quote) ...@@ -429,20 +432,14 @@ cpp_add_dependency_target (pfile, target, quote)
or stdin if it is the empty string. Return the original filename or stdin if it is the empty string. Return the original filename
on success (e.g. foo.i->foo.c), or NULL on failure. */ on success (e.g. foo.i->foo.c), or NULL on failure. */
const char * const char *
cpp_read_main_file (pfile, fname, table) cpp_read_main_file (pfile, fname)
cpp_reader *pfile; cpp_reader *pfile;
const char *fname; const char *fname;
hash_table *table;
{ {
sanity_checks (pfile); sanity_checks (pfile);
post_options (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. */ /* Mark named operators before handling command line macros. */
if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names)) if (CPP_OPTION (pfile, cplusplus) && CPP_OPTION (pfile, operator_names))
mark_named_operators (pfile); mark_named_operators (pfile);
......
...@@ -485,8 +485,13 @@ struct cpp_hashnode GTY(()) ...@@ -485,8 +485,13 @@ struct cpp_hashnode GTY(())
} GTY ((desc ("0"))) value; } GTY ((desc ("0"))) value;
}; };
/* Call this first to get a handle to pass to other functions. */ /* Call this first to get a handle to pass to other functions.
extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
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 /* Call this to change the selected language standard (e.g. because of
command line options). */ command line options). */
...@@ -518,14 +523,8 @@ extern void cpp_set_callbacks PARAMS ((cpp_reader *, cpp_callbacks *)); ...@@ -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 returns the name of the original file; this is the same as the
input file, except for preprocessed input. This will generate at input file, except for preprocessed input. This will generate at
least one file change callback, and possibly a line change callback least one file change callback, and possibly a line change callback
too. If there was an error opening the file, it returns NULL. too. If there was an error opening the file, it returns NULL. */
extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *));
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 *));
/* Set up built-ins like __FILE__. */ /* Set up built-ins like __FILE__. */
extern void cpp_init_builtins PARAMS ((cpp_reader *)); extern void cpp_init_builtins PARAMS ((cpp_reader *));
...@@ -708,7 +707,8 @@ extern int cpp_included PARAMS ((cpp_reader *, const char *)); ...@@ -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_make_system_header PARAMS ((cpp_reader *, int, int));
extern void cpp_simplify_path PARAMS ((char *)); extern void cpp_simplify_path PARAMS ((char *));
extern bool cpp_push_include PARAMS ((cpp_reader *, const 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 */ /* In cpppch.c */
struct save_macro_data; struct save_macro_data;
......
...@@ -622,7 +622,7 @@ read_scan_file (in_fname, argc, argv) ...@@ -622,7 +622,7 @@ read_scan_file (in_fname, argc, argv)
obstack_init (&scan_file_obstack); 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 = cpp_get_callbacks (scan_in);
cb->file_change = cb_file_change; cb->file_change = cb_file_change;
...@@ -632,7 +632,7 @@ read_scan_file (in_fname, argc, argv) ...@@ -632,7 +632,7 @@ read_scan_file (in_fname, argc, argv)
options->inhibit_warnings = 1; options->inhibit_warnings = 1;
options->inhibit_errors = 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); exit (FATAL_EXIT_CODE);
for (i = 0; i < argc; i += strings_processed) for (i = 0; i < argc; i += strings_processed)
...@@ -675,9 +675,9 @@ read_scan_file (in_fname, argc, argv) ...@@ -675,9 +675,9 @@ read_scan_file (in_fname, argc, argv)
true /* stdinc */, false /* cxx_stdinc */, true /* stdinc */, false /* cxx_stdinc */,
false /* verbose */); false /* verbose */);
cpp_rename_file (scan_in, "<built-in>"); cpp_change_file (scan_in, LC_RENAME, "<built-in>");
cpp_init_builtins (scan_in); 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. */ /* We are scanning a system header, so mark it as such. */
cpp_make_system_header (scan_in, 1, 0); cpp_make_system_header (scan_in, 1, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment