diff options
author | Per Bothner <per@bothner.com> | 2004-01-19 21:30:18 -0800 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2004-01-19 21:30:18 -0800 |
commit | 50f59cd71061055cc039bbe44b5c955747719ebb (patch) | |
tree | 15fcd6b635123af68ed69ca87bf633fa01f46d8e /gcc | |
parent | 9132fbb788b24bc4b03be723a42b16dd9f65e03f (diff) | |
download | gcc-50f59cd71061055cc039bbe44b5c955747719ebb.zip gcc-50f59cd71061055cc039bbe44b5c955747719ebb.tar.gz gcc-50f59cd71061055cc039bbe44b5c955747719ebb.tar.bz2 |
Move cpp_reader's line_maps field to a shared global.
* cpphash.h (cpp_reader): Rename line_maps field to line_table
and change the type to a pointer rather than a struct.
* cppinit.c (cpp_push_main_field): Adjust accordingly.
* cpplib.c (do_include_common, _cpp_do_file_change, cpp_get_callbacks):
Likewise.
* cppfiles.c (validate_pch): Likewise.
* cppmacro.c (_cpp_warn_if_unused_macro, _cpp_builtin_macro_text):
Likewise.
* cpperror.c (print_location): Likewise.
* cpplib.h (cpp_create_reader): New line_maps pointer parameter.
* cppinit.c (cpp_create_reader): Handle new parameter.
(cpp_destroy): Don't free line_maps - that's no longer our job.
* input.h (line_table): New variable.
* toplev.c (line_table): Declare variable.
(general_init): Initialize line_table.
* c-opts.c (c_common_init_options): Pass line_table to
cpp_create_reader.
* fix-header.c (read_scan_file): New local variable line_table.
Initialize, and pass it to cpp_create_reader.
* Makefile.in (LIBS, LIBDEPS): Add libcpp.a.
(C_AND_OBJC_OBJS, fix-header): Remove redundant libcpp.a.
From-SVN: r76198
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 27 | ||||
-rw-r--r-- | gcc/Makefile.in | 8 | ||||
-rw-r--r-- | gcc/c-opts.c | 2 | ||||
-rw-r--r-- | gcc/cpperror.c | 4 | ||||
-rw-r--r-- | gcc/cpphash.h | 2 | ||||
-rw-r--r-- | gcc/cppinit.c | 8 | ||||
-rw-r--r-- | gcc/cpplib.c | 6 | ||||
-rw-r--r-- | gcc/cpplib.h | 3 | ||||
-rw-r--r-- | gcc/cppmacro.c | 6 | ||||
-rw-r--r-- | gcc/fix-header.c | 4 | ||||
-rw-r--r-- | gcc/input.h | 4 | ||||
-rw-r--r-- | gcc/toplev.c | 3 |
12 files changed, 56 insertions, 21 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c2ae7ab..7dc7aee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,29 @@ -2003-01-20 Per Bothner <pbothner@apple.com> +2004-01-19 Per Bothner <per@bothner.com> + + Move cpp_reader's line_maps field to a shared global. + * cpphash.h (cpp_reader): Rename line_maps field to line_table + and change the type to a pointer rather than a struct. + * cppinit.c (cpp_push_main_field): Adjust accordingly. + * cpplib.c (do_include_common, _cpp_do_file_change, cpp_get_callbacks): + Likewise. + * cppfiles.c (validate_pch): Likewise. + * cppmacro.c (_cpp_warn_if_unused_macro, _cpp_builtin_macro_text): + Likewise. + * cpperror.c (print_location): Likewise. + * cpplib.h (cpp_create_reader): New line_maps pointer parameter. + * cppinit.c (cpp_create_reader): Handle new parameter. + (cpp_destroy): Don't free line_maps - that's no longer our job. + * input.h (line_table): New variable. + * toplev.c (line_table): Declare variable. + (general_init): Initialize line_table. + * c-opts.c (c_common_init_options): Pass line_table to + cpp_create_reader. + * fix-header.c (read_scan_file): New local variable line_table. + Initialize, and pass it to cpp_create_reader. + * Makefile.in (LIBS, LIBDEPS): Add libcpp.a. + (C_AND_OBJC_OBJS, fix-header): Remove redundant libcpp.a. + +2004-01-19 Per Bothner <per@bothner.com> Implement a cache for linemap_lookup. * line-map.h (struct_line_maps): Add cache field. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 3623f4c..a48a4f5 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -714,7 +714,7 @@ LIBIBERTY = ../libiberty/libiberty.a BUILD_LIBIBERTY = @FORBUILD@/libiberty/libiberty.a # Dependencies on the intl and portability libraries. -LIBDEPS= $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) +LIBDEPS= $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) libcpp.a # Likewise, for use in the tools that must run on this machine # even if we are cross-building GCC. @@ -722,7 +722,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY) # How to link with both our special library facilities # and the system's installed libraries. -LIBS = @LIBS@ $(LIBIBERTY) $(LIBINTL) $(LIBICONV) +LIBS = @LIBS@ libcpp.a $(LIBIBERTY) $(LIBINTL) $(LIBICONV) # Any system libraries needed just for GNAT. SYSLIBS = @GNAT_LIBEXC@ @@ -839,7 +839,7 @@ CXX_TARGET_OBJS=@cxx_target_objs@ C_AND_OBJC_OBJS = attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o \ c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o \ c-incpath.o cppdefault.o c-ppoutput.o c-cppbuiltin.o prefix.o \ - c-objc-common.o c-dump.o c-pch.o libcpp.a $(C_TARGET_OBJS) + c-objc-common.o c-dump.o c-pch.o $(C_TARGET_OBJS) # Language-specific object files for C. C_OBJS = c-parse.o c-lang.o c-pretty-print.o stub-objc.o $(C_AND_OBJC_OBJS) @@ -2571,7 +2571,7 @@ xsys-protos.h: $(GCC_PASSES) $(srcdir)/sys-protos.h deduced.h gen-protos$(build_ fix-header$(build_exeext): fix-header.o scan-decls.o scan.o xsys-protos.h \ c-incpath.o cppdefault.o prefix.o $(LIBDEPS) libcpp.a $(CC_FOR_BUILD) $(BUILD_CFLAGS) $(BUILD_LDFLAGS) -o $@ fix-header.o \ - c-incpath.o cppdefault.o scan-decls.o prefix.o scan.o libcpp.a $(LIBS) + c-incpath.o cppdefault.o scan-decls.o prefix.o scan.o $(LIBS) fix-header.o: fix-header.c $(OBSTACK_H) scan.h \ xsys-protos.h $(BCONFIG_H) $(SYSTEM_H) coretypes.h $(GTM_H) $(CPPLIB_H) diff --git a/gcc/c-opts.c b/gcc/c-opts.c index 59bce76..77d6688 100644 --- a/gcc/c-opts.c +++ b/gcc/c-opts.c @@ -203,7 +203,7 @@ c_common_init_options (unsigned int argc, const char **argv ATTRIBUTE_UNUSED) } parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89, - ident_hash); + ident_hash, &line_table); cpp_opts = cpp_get_options (parse_in); cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS; diff --git a/gcc/cpperror.c b/gcc/cpperror.c index 61763cc..268d4ee 100644 --- a/gcc/cpperror.c +++ b/gcc/cpperror.c @@ -45,8 +45,8 @@ print_location (cpp_reader *pfile, fileline line, unsigned int col) const struct line_map *map; unsigned int lin; - map = linemap_lookup (&pfile->line_maps, line); - linemap_print_containing_files (&pfile->line_maps, map); + map = linemap_lookup (pfile->line_table, line); + linemap_print_containing_files (pfile->line_table, map); lin = SOURCE_LINE (map, line); if (col == 0) diff --git a/gcc/cpphash.h b/gcc/cpphash.h index ddac566..a63121d 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -334,7 +334,7 @@ struct cpp_reader struct lexer_state state; /* Source line tracking. */ - struct line_maps line_maps; + struct line_maps *line_table; const struct line_map *map; fileline line; diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 629da27..b001c71 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -124,7 +124,8 @@ init_library (void) /* Initialize a cpp_reader structure. */ cpp_reader * -cpp_create_reader (enum c_lang lang, hash_table *table) +cpp_create_reader (enum c_lang lang, hash_table *table, + struct line_maps *line_table) { cpp_reader *pfile; @@ -172,7 +173,7 @@ cpp_create_reader (enum c_lang lang, hash_table *table) /* Initialize the line map. Start at logical line 1, so we can use a line number of zero for special states. */ - linemap_init (&pfile->line_maps); + pfile->line_table = line_table; pfile->line = 1; /* Initialize lexer state. */ @@ -262,7 +263,6 @@ cpp_destroy (cpp_reader *pfile) free (context); } - linemap_free (&pfile->line_maps); free (pfile); } @@ -501,7 +501,7 @@ cpp_push_main_file (cpp_reader *pfile) /* Set this here 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); + pfile->line_table->trace_includes = CPP_OPTION (pfile, print_include_names); } /* For preprocessed files, if the first tokens are of the form # NUM. diff --git a/gcc/cpplib.c b/gcc/cpplib.c index feb8717..0d1ab9a 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -681,7 +681,7 @@ do_include_common (cpp_reader *pfile, enum include_type type) return; /* Prevent #include recursion. */ - if (pfile->line_maps.depth >= CPP_STACK_MAX) + if (pfile->line_table->depth >= CPP_STACK_MAX) cpp_error (pfile, CPP_DL_ERROR, "#include nested too deeply"); else { @@ -900,7 +900,7 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason, const char *to_file, unsigned int file_line, unsigned int sysp) { - pfile->map = linemap_add (&pfile->line_maps, reason, sysp, + pfile->map = linemap_add (pfile->line_table, reason, sysp, pfile->line, to_file, file_line); if (pfile->cb.file_change) @@ -1907,7 +1907,7 @@ cpp_get_callbacks (cpp_reader *pfile) const struct line_maps * cpp_get_line_maps (cpp_reader *pfile) { - return &pfile->line_maps; + return pfile->line_table; } /* Copy the given callbacks structure to our own. */ diff --git a/gcc/cpplib.h b/gcc/cpplib.h index f7e12d2..9b91624 100644 --- a/gcc/cpplib.h +++ b/gcc/cpplib.h @@ -510,7 +510,8 @@ struct cpp_hashnode GTY(()) 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 (enum c_lang, struct ht *); +extern cpp_reader *cpp_create_reader (enum c_lang, struct ht *, + struct line_maps *); /* Call this to change the selected language standard (e.g. because of command line options). */ diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index efae0f0..158d926 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -80,7 +80,7 @@ _cpp_warn_if_unused_macro (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro = node->value.macro; if (!macro->used - && MAIN_FILE_P (linemap_lookup (&pfile->line_maps, macro->line))) + && MAIN_FILE_P (linemap_lookup (pfile->line_table, macro->line))) cpp_error_with_line (pfile, CPP_DL_WARNING, macro->line, 0, "macro \"%s\" is not used", NODE_NAME (node)); } @@ -136,7 +136,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) if (node->value.builtin == BT_BASE_FILE) while (! MAIN_FILE_P (map)) - map = INCLUDED_FROM (&pfile->line_maps, map); + map = INCLUDED_FROM (pfile->line_table, map); name = map->to_file; len = strlen (name); @@ -153,7 +153,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) /* The line map depth counts the primary source as level 1, but historically __INCLUDE_DEPTH__ has called the primary source level 0. */ - number = pfile->line_maps.depth - 1; + number = pfile->line_table->depth - 1; break; case BT_SPECLINE: diff --git a/gcc/fix-header.c b/gcc/fix-header.c index ad23793..282c516 100644 --- a/gcc/fix-header.c +++ b/gcc/fix-header.c @@ -590,10 +590,12 @@ read_scan_file (char *in_fname, int argc, char **argv) struct fn_decl *fn; int i, strings_processed; struct symbol_list *cur_symbols; + struct line_maps line_table; obstack_init (&scan_file_obstack); - scan_in = cpp_create_reader (CLK_GNUC89, NULL); + linemap_init (&line_table); + scan_in = cpp_create_reader (CLK_GNUC89, NULL, &line_table); cb = cpp_get_callbacks (scan_in); cb->file_change = cb_file_change; diff --git a/gcc/input.h b/gcc/input.h index ff014f6..3e00496 100644 --- a/gcc/input.h +++ b/gcc/input.h @@ -22,6 +22,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #ifndef GCC_INPUT_H #define GCC_INPUT_H +#include "line-map.h" + +extern struct line_maps line_table; + /* The data structure used to record a location in a translation unit. */ /* Long-term, we want to get rid of this and typedef fileline location_t. */ struct location_s GTY (()) diff --git a/gcc/toplev.c b/gcc/toplev.c index 0a2d607..4769c82b 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -189,6 +189,8 @@ const char *main_input_filename; location_t input_location; +struct line_maps line_table; + /* Nonzero if it is unsafe to create any new pseudo registers. */ int no_new_pseudos; @@ -4228,6 +4230,7 @@ general_init (const char *argv0) table. */ init_ggc (); init_stringpool (); + linemap_init (&line_table); init_ttree (); /* Initialize register usage now so switches may override. */ |