Patches to remove TREE_COMPLEXITY for C and C++

Per Bothner per@bothner.com
Tue Jul 20 12:24:00 GMT 2004


Richard Kenner wrote:
>     Anyplace where input_line is read or written without input_filename or
>     vice versa needs to be examined.  
> 
>     I have no idea about Ada.
> 
> It handles file reading totally independently and has a routine to convert
> its internal location into a GCC location.  See ada/trans.c:Sloc_to_locus.
> If any changes are needed, it'll just be there.  (There's a Get_Column_Number
> that can be called like Get_Logical_Line_Number there.)

If we don't care about column numbers, it's relatively easy to
implement a (filename, line) -> source_location mapping.

If we don't care about column numbers, it's somewhat trickier.
The issue is that we only have sizeof(unsigned int)*8 bits
available total for the entire compilation:  If you compile
multiple module or we implement a compile server, you don't get
to reuse source_location values.

In either case, the code is written and optimized for the case
the (line, column) numbers are allocated during lexing as the
code is read in, since that's what cpplib does, but other
strategies are possible.

It appears that Ada has the entire source file in memory:  The
Source_Loc is an actual index in a buffer.  That gives you some
flexibility in how you manage source_locations.

"Managing" source_locations means when and how you call linemap_add,
linemap_line_start, and LINEMAP_POSITION_FOR_COLUMN.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Gcc-patches mailing list