[cfe-dev] Preprocessed loc/token retrieval dream (almost) come true

Argyrios Kyrtzidis kyrtzidis at apple.com
Tue Oct 4 09:37:19 PDT 2011


On Oct 4, 2011, at 9:27 AM, Abramo Bagnara wrote:

> Il 03/10/2011 21:10, Argyrios Kyrtzidis ha scritto:
>> On Oct 3, 2011, at 11:57 AM, Abramo Bagnara wrote:
>> 
>>> Il 03/10/2011 20:25, Argyrios Kyrtzidis ha scritto:
>>>> Hi Abramo,
>>>> 
>>>> Sorry to disappoint you but I think the dream remains unfulfilled ;-)
>>> 
>>> You make me sad for a few minutes... but let try to find a solution: I
>>> think that to get preprocessed tokens has too many benefits to stop only
>>> a few steps before to accomplish that.
>>> 
>>> Let me know if you don't see strong benefits in the possibility to get
>>> the preprocessed tokens in a range.
>>> 
>>> First the easy part:
>>> 
>>>> Apart from that, this is trying to deal with macro expansions; how are
>>> you handling preprocessor directives ? e..g:
>>>> 
>>>> X
>>>> #if  ...
>>>> Y
>>>> #else
>>>> X
>>>> #endif
>>>> 
>>>> How do you find out what comes after 'X' if you don't preprocess ?
>>> 
>>> Preprocessor callbacks give us complete info about skipped area so the
>>> helper just have to take in account that.
>>> 
>>> The same is true for file changes:
>>> 
>>> X
>>> #include "..."
>>> Y
>> 
>> How about investigating whether it is possible/viable to extend the preprocessor callbacks in a way that you can get at the macro expanded locations/tokens in a reliable way ?
> 
> One way might be to call a post expansion callback passing the expanded
> tokens, but I'm not sure this might be accepted in trunk...

I think it is reasonable if it is opt-in, that is, the preprocessor callback implementer indicates that it wants or not the preprocessor to provide such info.

> 
> Do you have better ideas?
> 




More information about the cfe-dev mailing list