@@ -26,6 +26,18 @@ along with this program; see the file COPYING3. If not see
26
26
#include "internal.h"
27
27
#include "hashtab.h"
28
28
29
+ /* Do not track column numbers higher than this one. As a result, the
30
+ range of column_bits is [7, 18] (or 0 if column numbers are
31
+ disabled). */
32
+ const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 17 );
33
+
34
+ /* Do not track column numbers if locations get higher than this. */
35
+ const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000 ;
36
+
37
+ /* Highest possible source location encoded within an ordinary or
38
+ macro map. */
39
+ const source_location LINE_MAP_MAX_SOURCE_LOCATION = 0x70000000 ;
40
+
29
41
static void trace_include (const struct line_maps * , const line_map_ordinary * );
30
42
static const line_map_ordinary * linemap_ordinary_map_lookup (struct line_maps * ,
31
43
source_location );
@@ -544,22 +556,23 @@ linemap_line_start (struct line_maps *set, linenum_type to_line,
544
556
|| (max_column_hint >= (1U << ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map )))
545
557
|| (max_column_hint <= 80
546
558
&& ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map ) >= 10 )
547
- || (highest > 0x60000000
548
- && (set -> max_column_hint || highest > 0x70000000 )))
559
+ || (highest > LINE_MAP_MAX_LOCATION_WITH_COLS
560
+ && (set -> max_column_hint || highest >= LINE_MAP_MAX_SOURCE_LOCATION )))
549
561
add_map = true;
550
562
else
551
563
max_column_hint = set -> max_column_hint ;
552
564
if (add_map )
553
565
{
554
566
int column_bits ;
555
- if (max_column_hint > 100000 || highest > 0x60000000 )
567
+ if (max_column_hint > LINE_MAP_MAX_COLUMN_NUMBER
568
+ || highest > LINE_MAP_MAX_LOCATION_WITH_COLS )
556
569
{
557
570
/* If the column number is ridiculous or we've allocated a huge
558
571
number of source_locations, give up on column numbers. */
559
572
max_column_hint = 0 ;
560
- if (highest > 0x70000000 )
561
- return 0 ;
562
573
column_bits = 0 ;
574
+ if (highest > LINE_MAP_MAX_SOURCE_LOCATION )
575
+ return 0 ;
563
576
}
564
577
else
565
578
{
@@ -615,7 +628,8 @@ linemap_position_for_column (struct line_maps *set, unsigned int to_column)
615
628
616
629
if (to_column >= set -> max_column_hint )
617
630
{
618
- if (r >= 0xC000000 || to_column > 100000 )
631
+ if (r > LINE_MAP_MAX_LOCATION_WITH_COLS
632
+ || to_column > LINE_MAP_MAX_COLUMN_NUMBER )
619
633
{
620
634
/* Running low on source_locations - disable column numbers. */
621
635
return r ;
0 commit comments