Skip to content

Commit 0d344d2

Browse files
author
manu
committedMay 26, 2015
libcpp/ChangeLog:
2015-05-26 Manuel López-Ibáñez <manu@gcc.gnu.org> * line-map.c (LINE_MAP_MAX_COLUMN_NUMBER LINE_MAP_MAX_LOCATION_WITH_COLS,LINE_MAP_MAX_SOURCE_LOCATION): New constants. (linemap_line_start): Use them. (linemap_position_for_column): Use them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223705 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent b11ca81 commit 0d344d2

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed
 

‎libcpp/ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2015-05-26 Manuel López-Ibáñez <manu@gcc.gnu.org>
2+
3+
* line-map.c (LINE_MAP_MAX_COLUMN_NUMBER
4+
LINE_MAP_MAX_LOCATION_WITH_COLS,LINE_MAP_MAX_SOURCE_LOCATION):
5+
New constants.
6+
(linemap_line_start): Use them.
7+
(linemap_position_for_column): Use them.
8+
19
2015-05-20 David Malcolm <dmalcolm@redhat.com>
210

311
* include/line-map.h (MAP_START_LOCATION): Eliminate the non-const

‎libcpp/line-map.c

+20-6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ along with this program; see the file COPYING3. If not see
2626
#include "internal.h"
2727
#include "hashtab.h"
2828

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+
2941
static void trace_include (const struct line_maps *, const line_map_ordinary *);
3042
static const line_map_ordinary * linemap_ordinary_map_lookup (struct line_maps *,
3143
source_location);
@@ -544,22 +556,23 @@ linemap_line_start (struct line_maps *set, linenum_type to_line,
544556
|| (max_column_hint >= (1U << ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map)))
545557
|| (max_column_hint <= 80
546558
&& 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)))
549561
add_map = true;
550562
else
551563
max_column_hint = set->max_column_hint;
552564
if (add_map)
553565
{
554566
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)
556569
{
557570
/* If the column number is ridiculous or we've allocated a huge
558571
number of source_locations, give up on column numbers. */
559572
max_column_hint = 0;
560-
if (highest > 0x70000000)
561-
return 0;
562573
column_bits = 0;
574+
if (highest > LINE_MAP_MAX_SOURCE_LOCATION)
575+
return 0;
563576
}
564577
else
565578
{
@@ -615,7 +628,8 @@ linemap_position_for_column (struct line_maps *set, unsigned int to_column)
615628

616629
if (to_column >= set->max_column_hint)
617630
{
618-
if (r >= 0xC000000 || to_column > 100000)
631+
if (r > LINE_MAP_MAX_LOCATION_WITH_COLS
632+
|| to_column > LINE_MAP_MAX_COLUMN_NUMBER)
619633
{
620634
/* Running low on source_locations - disable column numbers. */
621635
return r;

0 commit comments

Comments
 (0)
Please sign in to comment.