[cfe-dev] A small proposal about TagType's and source ranges

John McCall rjmccall at apple.com
Tue Mar 15 00:59:03 PDT 2011


On Mar 15, 2011, at 12:46 AM, Abramo Bagnara wrote:
> Il 15/03/2011 07:39, John McCall ha scritto:
>> Having precise source locations is certainly a desirable goal, but it does
>> need to be balanced against other goals like keeping memory usage
>> reasonable.  For example, we could theoretically store the locations of
>> semicolons and commas, but we don't, because we assume it's possible to
>> discover them by re-lexing from a known location.
> 
> ... this is a big surprise for me. In the general case how you'd cope
> with macro expansion?

Badly, I expect.  I believe the thinking is that we would rather have an API
which relexes the entire translation unit up to a point than to waste what's
quite likely to be dozens of megabytes per translation unit storing
unnecessary commas, equals signs, and semicolons.

We don't currently have such an API only because nobody has written it
yet, which is probably related to the fact that it's hard to imagine why anyone
would both (1) have an interest in that level of source information *and*
(2) be able to proceed with their intended operation in the face of macros.
Certainly most refactoring engines have no business operating within
macros.

John.



More information about the cfe-dev mailing list