PATCH column number support

Per Bothner per@bothner.com
Tue Dec 2 08:17:00 GMT 2003


Richard Henderson wrote:

> I'd like to have some check for exhausting map space.  This was
> possible before with extraordinarily large inputs, but with the column
> space now allocated, you've made it two orders of magnitude easier.  I
> don't know if an abort is viable; forcing saturation at UINT_MAX and
> letting that print as "<line number overflow>:0:0" sounds plausable.
> 
> What do we do if the user writes "#line 33554432"?  or 10000000000?
> Does this differ between 32 and 64-bit hosts?

In both this case (an "unreasonably" high line number) or in the
case of "running low" we might want to have an option for disabling
column numbers.  "Running low" might be defined as after handing
out 0x8000000.

However, this might complicate the API.  I was thinking of:

/* Get location for start of LINE and up to MAX_COL columns.
    The client gets a source_location L such that L stands for
    "column 0" of LINE, and L+C is column C of LINE, upto C<=MAX_COL. */
#define LINEMAP_NEW_LINE(MAPS, LINE, MAX_COL) ...

to be used thus:

/* current_line_width has been calculated by _cpp_clean_line */
pfile->line_start_loc
    = LINEMAP_NEW_LINE(&pfile->line_maps, current_line_number,
                       current_line_width);

token->src_loc
    = pfile->line_start_loc + CPP_BUF_COLUMN (buffer, buffer->cur)

It gets a little uglier if we have to check for "running low".
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/




More information about the Gcc-patches mailing list