line-map question

Devang Patel dpatel@apple.com
Mon Apr 18 20:36:00 GMT 2005


On Apr 18, 2005, at 11:54 AM, Mike Stump wrote:

> On Apr 18, 2005, at 9:55 AM, Devang Patel wrote:
>> From line_map comment at (libcpp/include/line-map.h)
>>
>> /* Physical source file TO_FILE at line TO_LINE at column 0 is  
>> represented
>>    by the logical START_LOCATION.  TO_LINE+L at column C is  
>> represented by
>>    START_LOCATION+(L*(1<<column_bits))+C, as long as C< 
>> (1<<column_bits),
>>
>> What happens when column number is >= 128 ? This is PR 20907.
>
> What should happen?  Well, col==0 would be reasonable.

Well, column 0 is represented as START_LOCATION. Some how, when  
column number
is >= 128, line-map increments physical line number. And I am kind of  
lost
reading code without any kind of comments ;-( See below from line-map.c.

-
Devang


   return map;
}

source_location
linemap_line_start (struct line_maps *set, unsigned int to_line,
                     unsigned int max_column_hint)
{
   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, set->highest_line);
   int line_delta = to_line - last_line;
   bool add_map = false;
   if (line_delta < 0
       || (line_delta > 10 && line_delta * map->column_bits > 1000)
       || (max_column_hint >= (1U << map->column_bits))
       || (max_column_hint <= 80 && map->column_bits >= 10))
     {
       add_map = true;
     }
   else
     max_column_hint = set->max_column_hint;
   if (add_map)
     {
       int column_bits;
       if (max_column_hint > 100000 || highest > 0xC0000000)
         {
           max_column_hint = 0;
           if (highest >0xF0000000)
             return 0;
           column_bits = 0;
         }
       else
         {
           column_bits = 7;
           while (max_column_hint >= (1U << column_bits))
             column_bits++;
           max_column_hint = 1U << column_bits;
         }
       if (line_delta < 0
           || last_line != map->to_line
           || SOURCE_COLUMN (map, highest) >= (1U << column_bits))
         map = (struct line_map*) linemap_add (set, LC_RENAME, map- 
 >sysp,
                                       map->to_file, to_line);
       map->column_bits = column_bits;
       r = map->start_location;
     }
   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;
}




More information about the Gcc mailing list