aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2004-04-22 19:22:27 -0700
committerPer Bothner <bothner@gcc.gnu.org>2004-04-22 19:22:27 -0700
commit500bee0adc06da520a9b8b3afde33afee6f314f3 (patch)
tree04a13ceb8485dc1405388eb42a55f0a9c7a8ebbc /gcc/cpplib.c
parent9344fdb9407d69218d02c2e509a358e80cf64eb6 (diff)
downloadgcc-500bee0adc06da520a9b8b3afde33afee6f314f3.zip
gcc-500bee0adc06da520a9b8b3afde33afee6f314f3.tar.gz
gcc-500bee0adc06da520a9b8b3afde33afee6f314f3.tar.bz2
line-map.h (struct line_maps): New field highest_line.
* line-map.h (struct line_maps): New field highest_line. (linemap_position_for_column): Make non-inline function. (LINEMAP_POSITION_FOR_COLUMN): New macro. * line-map.c (linemap_init): Clear highest_line field. (linemap_add): Set highest_line field. (linemap_line_start): Minor optimization - use highest_line field. Reduce maximum column hint to 10000. Update highest_line field. (linemap_position_for_column): Moved from line-map.h. Optimize a bit. * cpphash.h (struct cpp_reader): Remove line field - instead use line_table->highest_line. (saved_line): Remove unused field. (CPP_INCREMENT_FILE): Don't do linemap_lookup - just use newest map. Use line_table's highest_line field instead of cpp_reader's line. * cpplib.c (start_directive): Likewise use highest_line field. (do_line, do_linemarker): Likewise just use newest map. (_cpp_do_file_change): Don't need to set cpp_reader's line field. * cpperror.c (cpp_error): Likewise use highest_line field. * cppfiles.c (open_file_failed: Likewise. (cpp_make_system_header): Likewise use newest map and highest_line. * cppinit.c (cpp_create_reader): Don't initialize removed field. * cpplex.c (_cpp_process_line_notes, _cpp_skip_block_comment, skip_line_comment, skip_whitespace, _cpp_get_fresh_line, _cpp_lex_direct): Likewise use highest_line. (_cpp_lex_direct): Use new LINEMAP_POSITION_FOR_COLUMN macro. * cppmacro.c (_cpp_builtin_macro_text): Likewise use highest_line, and use newest map. * cpppch.c (cpp_read_state): Don't save+restore cpp_reader's line. * cpptrad.c (_cpp_overlay_buffer): Don't save cpp_reader's line. (copy_comment, _cpp_scan_out_logical_line): Likewise use highest_line. From-SVN: r81074
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 80adfb8..808dcda 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -228,7 +228,7 @@ start_directive (cpp_reader *pfile)
pfile->state.save_comments = 0;
/* Some handlers need the position of the # for diagnostics. */
- pfile->directive_line = pfile->line;
+ pfile->directive_line = pfile->line_table->highest_line;
}
/* Called when leaving a directive, _Pragma or command-line directive. */
@@ -777,7 +777,8 @@ strtoul_for_line (const uchar *str, unsigned int len, long unsigned int *nump)
static void
do_line (cpp_reader *pfile)
{
- const struct line_map *map = linemap_lookup (pfile->line_table, pfile->line);
+ const struct line_maps *line_table = pfile->line_table;
+ const struct line_map *map = &line_table->maps[line_table->used - 1];
const cpp_token *token;
const char *new_file = map->to_file;
unsigned long new_lineno;
@@ -827,7 +828,8 @@ do_line (cpp_reader *pfile)
static void
do_linemarker (cpp_reader *pfile)
{
- const struct line_map *map = linemap_lookup (pfile->line_table, pfile->line);
+ const struct line_maps *line_table = pfile->line_table;
+ const struct line_map *map = &line_table->maps[line_table->used - 1];
const cpp_token *token;
const char *new_file = map->to_file;
unsigned long new_lineno;
@@ -907,10 +909,8 @@ _cpp_do_file_change (cpp_reader *pfile, enum lc_reason reason,
{
const struct line_map *map = linemap_add (pfile->line_table, reason, sysp,
to_file, file_line);
- if (map == NULL)
- pfile->line = 0;
- else
- pfile->line = linemap_line_start (pfile->line_table, map->to_line, 127);
+ if (map != NULL)
+ linemap_line_start (pfile->line_table, map->to_line, 127);
if (pfile->cb.file_change)
pfile->cb.file_change (pfile, map);