diff options
author | Per Bothner <per@bothner.com> | 2004-04-22 19:22:27 -0700 |
---|---|---|
committer | Per Bothner <bothner@gcc.gnu.org> | 2004-04-22 19:22:27 -0700 |
commit | 500bee0adc06da520a9b8b3afde33afee6f314f3 (patch) | |
tree | 04a13ceb8485dc1405388eb42a55f0a9c7a8ebbc /gcc/line-map.c | |
parent | 9344fdb9407d69218d02c2e509a358e80cf64eb6 (diff) | |
download | gcc-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/line-map.c')
-rw-r--r-- | gcc/line-map.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/gcc/line-map.c b/gcc/line-map.c index ceb57d4..e7d41b6 100644 --- a/gcc/line-map.c +++ b/gcc/line-map.c @@ -40,6 +40,7 @@ linemap_init (struct line_maps *set) set->depth = 0; set->cache = 0; set->highest_location = 0; + set->highest_line = 0; set->max_column_hint = 0; } @@ -154,6 +155,7 @@ linemap_add (struct line_maps *set, enum lc_reason reason, set->cache = set->used++; map->column_bits = 0; set->highest_location = start_location; + set->highest_line = start_location; set->max_column_hint = 0; if (reason == LC_ENTER) @@ -181,7 +183,7 @@ linemap_line_start (struct line_maps *set, unsigned int to_line, struct line_map *map = &set->maps[set->used - 1]; source_location highest = set->highest_location; source_location r; - unsigned int last_line = SOURCE_LINE (map, highest); + unsigned int last_line = SOURCE_LINE (map, set->highest_line); int line_delta = to_line - last_line; bool add_map = false; if (line_delta < 0 @@ -196,7 +198,7 @@ linemap_line_start (struct line_maps *set, unsigned int to_line, if (add_map) { int column_bits; - if (max_column_hint > 1000000 || highest > 0xC0000000) + if (max_column_hint > 100000 || highest > 0xC0000000) { max_column_hint = 0; if (highest >0xF0000000) @@ -221,12 +223,36 @@ linemap_line_start (struct line_maps *set, unsigned int to_line, else r = highest - SOURCE_COLUMN (map, highest) + (line_delta << map->column_bits); + set->highest_line = r; if (r > set->highest_location) set->highest_location = r; set->max_column_hint = max_column_hint; return r; } +source_location +linemap_position_for_column (struct line_maps *set, unsigned int to_column) +{ + source_location r = set->highest_line; + if (to_column >= set->max_column_hint) + { + if (r >= 0xC000000 || to_column > 100000) + { + /* Running low on source_locations - disable column numbers. */ + return r; + } + else + { + struct line_map *map = &set->maps[set->used - 1]; + r = linemap_line_start (set, SOURCE_LINE (map, r), to_column + 50); + } + } + r = r + to_column; + if (r >= set->highest_location) + set->highest_location = r; + return r; +} + /* Given a logical line, returns the map from which the corresponding (source file, line) pair can be deduced. Since the set is built chronologically, the logical lines are monotonic increasing, and so |