https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65536

--- Comment #17 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #16)
> Other easier to implement idea for GCC 5 may be to simply collect locaiton

For GCC 5 you should just disable column numbers in line-maps. This will save
you a lot of source_locations before overflowing. If you don't overflow the
source_locations themselves, then the line numbers at least should come out
right.

Something like this (not even compiled):


Index: src/libcpp/include/line-map.h
===================================================================
--- src/libcpp/include/line-map.h       (revision 221557)
+++ src/libcpp/include/line-map.h       (working copy)
@@ -88,10 +88,14 @@ struct GTY(()) line_map_ordinary {

 /* This is the highest possible source location encoded within an
    ordinary or macro map.  */
 #define MAX_SOURCE_LOCATION 0x7FFFFFFF

+/* We do not track column numbers higher than this one.  */
+#define LINE_MAP_MAX_COLUMN_NUMBER 100000
+
+
 struct cpp_hashnode;

 /* A macro line map encodes location of tokens coming from a macro
    expansion.

Index: src/libcpp/line-map.c
===================================================================
--- src/libcpp/line-map.c       (revision 221557)
+++ src/libcpp/line-map.c       (working copy)
@@ -536,11 +536,11 @@ linemap_line_start (struct line_maps *se
   else
     max_column_hint = set->max_column_hint;
   if (add_map)
     {
       int column_bits;
-      if (max_column_hint > 100000 || highest > 0x60000000)
+      if (max_column_hint > LINE_MAP_MAX_COLUMN_NUMBER || highest >
0x60000000)
        {
          /* If the column number is ridiculous or we've allocated a huge
             number of source_locations, give up on column numbers. */
          max_column_hint = 0;
          if (highest > 0x70000000)
@@ -598,11 +598,11 @@ linemap_position_for_column (struct line
   linemap_assert
     (!linemap_macro_expansion_map_p (LINEMAPS_LAST_ORDINARY_MAP (set)));

   if (to_column >= set->max_column_hint)
     {
-      if (r >= 0xC000000 || to_column > 100000)
+      if (r >= 0xC000000 || to_column > LINE_MAP_MAX_COLUMN_NUMBER)
        {
          /* Running low on source_locations - disable column numbers.  */
          return r;
        }
       else
Index: src/gcc/lto-streamer-in.c
===================================================================
--- src/gcc/lto-streamer-in.c   (revision 221557)
+++ src/gcc/lto-streamer-in.c   (working copy)
@@ -198,21 +198,23 @@ lto_input_location (struct bitpack_d *bp
     current_line = bp_unpack_var_len_unsigned (bp);

   if (column_change)
     current_col = bp_unpack_var_len_unsigned (bp);

-  if (file_change)
+  if (file_change) 
     {
       if (prev_file)
-       linemap_add (line_table, LC_LEAVE, false, NULL, 0);
-
-      linemap_add (line_table, LC_ENTER, false, current_file, current_line);
+       linemap_add (line_table, LC_RENAME, false, current_file, current_line);
+      else
+       linemap_add (line_table, LC_ENTER, false, current_file, current_line);
     }
   else if (line_change)
-    linemap_line_start (line_table, current_line, current_col);
+    /* Enough column_hint to disable columns */
+    return linemap_line_start (line_table, current_line,
LINE_MAP_MAX_COLUMN_NUMBER + 1);

-  return linemap_position_for_column (line_table, current_col);
+  /* Enough column_hint to disable columns */
+  return linemap_position_for_column (line_table, LINE_MAP_MAX_COLUMN_NUMBER +
1);
 }


 /* Read a reference to a tree node from DATA_IN using input block IB.
    TAG is the expected node that should be found in IB, if TAG belongs

Reply via email to