[cfe-dev] libelling - tokens/AST and the preprocessor

Vladimir Voskresensky voskresensky.vladimir at gmail.com
Mon Mar 2 22:49:28 PST 2015


Hello,

When create Preprocessor add own PPCallbacks impl with implemented 
SourceRangeSkipped to track dead blocks.

Hope it helps,
Vladimir.

On 03/03/2015 01:12 AM, R J Cooper wrote:
> So libclang makes tokenising and thus syntax highlighting easy; but ... what I'm struggling with is #ifdef blocks - specifically those which are compiled (out as I want to highlight them differently)
>
> A quick test show that given the following code:
>
> #ifdef EXCLUDE
> int a = 0;
> #endif
>
> I always get the same tokens (#, ifdef, EXCLUDE, int, a, =, 0, ;, #, endif).  But depending on the value of EXCLUDE the AST behind those tokens changes - when excluded they are all put in a single COMPOUND_STMT.
>
> The question is, how do I tell these tokens have been excluded from the compile; and thus I can mark them as dimmed?
>
> I've tried most things I can think of but still can't figure out how to take an AST cursor and get if it was actually included.
>
> Thanks
>
> Rich
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list