aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPer Bothner <pbothner@apple.com>2003-03-20 16:46:18 +0000
committerPer Bothner <bothner@gcc.gnu.org>2003-03-20 08:46:18 -0800
commitb4e46cea24515316b941bfacae8417c078fc5701 (patch)
treecff696dfa377a0cf3e735f28e287645b12baeba7 /gcc
parent8826ff0fcd12a506e2e91df9e4cae05747b88f13 (diff)
downloadgcc-b4e46cea24515316b941bfacae8417c078fc5701.zip
gcc-b4e46cea24515316b941bfacae8417c078fc5701.tar.gz
gcc-b4e46cea24515316b941bfacae8417c078fc5701.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/c-opts.c11
-rw-r--r--gcc/cppfiles.c10
-rw-r--r--gcc/cppinit.c13
-rw-r--r--gcc/cpplib.h22
-rw-r--r--gcc/fix-header.c8
6 files changed, 49 insertions, 32 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fe92cf9..b79f2bd 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 8c639cc..5de5019 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, _("<built-in>"));
+ cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
cpp_init_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++)
{
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 <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. */
cpp_opts->warn_unused_macros = warn_unused_macros;
include_cursor++;
diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c
index 9bcdb9e..1ff34ff 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 <built-in>. */
+/* Allow the client to change the current file. Used by the front end
+ to achieve pseudo-file names like <built-in>.
+ 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 abfcc50..376d72e 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 edd521b..ec5f8e4 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 8434cce..423cd57 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, "<built-in>");
+ cpp_change_file (scan_in, LC_RENAME, "<built-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. */
cpp_make_system_header (scan_in, 1, 0);