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.
#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;
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;
{
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];
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++;
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.
/* 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;
_cpp_init_includes (pfile);
+ _cpp_init_hashtable (pfile, table);
+
return pfile;
}
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);
} 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). */
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 *));
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;
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;
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)
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);