On 10/23/2015 02:41 PM, David Malcolm wrote:
gcc/ada/ChangeLog:
* gcc-interface/trans.c (Sloc_to_locus): Add line_table param when
calling linemap_position_for_line_and_column.
gcc/ChangeLog:
* input.c (dump_line_table_statistics): Dump stats on how many
ranges were optimized vs how many needed ad-hoc table.
(write_digit_row): Add "map" param; use its range_bits
to calculate the per-character offset.
(dump_location_info): Print the range and column bits for each
ordinary map. Use the range bits to calculate the per-character
offset. Pass the map as a new param to the various calls to
write_digit_row. Eliminate uses of
ORDINARY_MAP_NUMBER_OF_COLUMN_BITS.
* toplev.c (general_init): Initialize line_table's
default_range_bits.
* tree.c (get_pure_location): New function.
(set_block): Use the pure form of the location for the
caret in the combined location.
(set_source_range): Likewise.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c (get_loc): Add
line_table param when calling
linemap_position_for_line_and_column.
* gcc.dg/plugin/diagnostic_plugin_test_tree_expression_range.c
(emit_warning): Remove restriction that "loc" must be ad-hoc.
libcpp/ChangeLog:
* include/line-map.h (source_location): Update the descriptive
comment to reflect the packing scheme for short ranges.
(struct line_map_ordinary): Drop field "column_bits" in favor
of field "m_column_and_range_bits"; add field "m_range_bits".
(ORDINARY_MAP_NUMBER_OF_COLUMN_BITS): Delete.
(struct line_maps): Add fields "default_range_bits",
"num_optimized_ranges" and "num_unoptimized_ranges".
(get_range_from_adhoc_loc): Delete prototype.
(get_range_from_loc): Convert from an inline function to a
prototype.
(pure_location_p): New prototype.
(SOURCE_LINE): Update for renaming of column_bits.
(SOURCE_COLUMN): Likewise. Shift the column right by the map's
range_bits.
(LAST_SOURCE_LINE_LOCATION): Update for renaming of column_bits.
(linemap_position_for_line_and_column): Add line_maps * params.
* lex.c (_cpp_lex_direct): Don't attempt to record token ranges
for UNKNOWN_LOCATION and BUILTINS_LOCATION.
* line-map.c (LINE_MAP_MAX_COLUMN_NUMBER): Reduce from 1U << 17 to
1U << 9.
(can_be_stored_compactly_p): New function.
(get_combined_adhoc_loc): Implement bit-packing scheme for short
ranges.
(get_range_from_adhoc_loc): Make static.
(get_range_from_loc): New function.
(pure_location_p): New function.
(linemap_add): Ensure that start_location has zero for the
range_bits, unless we're past LINE_MAP_MAX_LOCATION_WITH_COLS.
Initialize range_bits to zero. Assert that the start_location
is "pure".
(linemap_line_start): Assert that the
column_and_range_bits >= range_bits.
Update determinination of whether we need to start a new map
using the effective column bits, without the range bits.
Use the set's default_range_bits in new maps, apart from
those with column_bits == 0, which should also have 0 range_bits.
Increase the column bits for new maps by the range bits.
When adding lines to an existing map, use set->highest_line
directly rather than offsetting highest by SOURCE_COLUMN.
Add assertions to sanity-check the return value.
(linemap_position_for_column): Offset to_column by range_bits.
Update set->hightest_location if necessary.
(linemap_position_for_line_and_column): Add line_maps * param.
Update the calculation to offset the column by range_bits, and
conditionalize it on being <= LINE_MAP_MAX_LOCATION_WITH_COLS.
Bound it by LINEMAPS_MACRO_LOWEST_LOCATION. Update
set->highest_location if necessary.
(linemap_position_for_loc_and_offset): Pass "set" to
linemap_position_for_line_and_column.
* location-example.txt: Regenerate, showing new representation.
"determinination"? :-)
---
gcc/ada/gcc-interface/trans.c | 3 +-
gcc/input.c | 28 ++-
.../plugin/diagnostic_plugin_test_show_locus.c | 3 +-
.../diagnostic_plugin_test_tree_expression_range.c | 8 +-
gcc/toplev.c | 1 +
gcc/tree.c | 25 ++-
libcpp/include/line-map.h | 121 +++++++----
libcpp/lex.c | 9 +-
libcpp/line-map.c | 229 +++++++++++++++++++--
libcpp/location-example.txt | 188 +++++++++--------
10 files changed, 450 insertions(+), 165 deletions(-)
diff --git a/gcc/tree.c b/gcc/tree.c
index a676352..4ec4a38 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -13653,11 +13653,31 @@ nonnull_arg_p (const_tree arg)
return false;
}
+static location_t
+get_pure_location (location_t loc)
Function comment.
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index 0ef29d9..1a2dab8 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
> @@ -821,8 +871,10 @@ extern source_location get_combined_adhoc_loc
(struct line_maps *,
extern void *get_data_from_adhoc_loc (struct line_maps *, source_location);
extern source_location get_location_from_adhoc_loc (struct line_maps *,
source_location);
-extern source_range get_range_from_adhoc_loc (struct line_maps *,
- source_location);
+
+extern source_range
+get_range_from_loc (line_maps *set,
+ source_location loc);
Nit. Should probably all be on one line.
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 6385fdf..fe8d784 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -29,7 +29,7 @@ along with this program; see the file COPYING3. If not see
/* Do not track column numbers higher than this one. As a result, the
range of column_bits is [7, 18] (or 0 if column numbers are
disabled). */
-const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 17);
+const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 9);
Comment needs updating, right?
+/* Helper function for get_combined_adhoc_loc.
+ Can the given LOCUS + SRC_RANGE and DATA pointer be stored compactly
+ within a source_location, without needing to use an ad-hoc location. */
+
+static bool
+can_be_stored_compactly_p (struct line_maps *set,
+ source_location locus,
+ source_range src_range,
+ void *data)
+{
+ /* If there's an ad-hoc pointer, we can't store it directly in the
+ source_location, we need the lookaside. */
+ if (data)
+ return false;
+
+ /* We only store ranges that begin at the locus and that are sufficientl
sufficiently
+
+#define DEBUG_PACKING 0
+
+#if DEBUG_PACKING
+ fprintf (stderr, "get_combined_adhoc_loc: %x %x %x\n",
+ locus, src_range.m_start, src_range.m_finish);
+#endif
Shouldn't this stuff (DEBUG_PACKING) just go away?
With the nits above fixed, this is OK. Obviously there's prereqs that
need to be approved and committed together.
jeff