[PATCH] Add debug method to visualize complex source locations

Manuel Klimek klimek at google.com
Wed May 8 11:49:45 PDT 2013


On Wed, May 8, 2013 at 6:42 PM, Chandler Carruth <chandlerc at google.com>wrote:

>
> On Wed, May 8, 2013 at 5:36 PM, Manuel Klimek <klimek at google.com> wrote:
>
>> In preparation for some docs on source locations I want to write I came up
>> with the little helper method that visualizes source locations as a tree.
>> This is especially helpful when you have many nested levels of macro
>> expansions.
>>
>> Example output:
>> (SP=(:6:14),
>>  EX=(SP=(:2:14),
>>      ES=(:6:8),
>>      EE=(:6:15)))
>>
>> SP = spelling
>> EX = expansion (if there's only a single location)
>> ES/EE = expansion start, expansion end (in case there's a range)
>>
>> Feel free to bikeshed about the details :D
>>
>
> Two high-level questions unrelated to the code itself:
>
> 1) Should we visualize these trees in roughly the same tree-ish syntax as
> AST trees? Or is it useful to visualize them on a single line *inside* the
> AST tree?
>

I'm all for bike shed color ideas: can you create a paste with how you want
it to look? (I tried a few things, and they all looked bad - I'm no good at
that :P)


> 2) Is there a way to make this part of the testing of source locations
> which is currently done mostly through c-index-test's testing of the
> writing out of cursor details from libclang?
>

Not sure - I really want a format that's for users; I'd be happy to create
something more machine-readable (JSON for example), so we can use it in
tests, though.

One nit-picky detail: please don't use the initialisms.... At least, not
> *these*. I see SP, EX, and ES in this syntax and I think "wait, is this a
> stack machine asm chunk?? some other weird assembly language?" before my
> mind returns to sanity. ;]
>

Just tell me what to use :) I don't have strong feelings about anything
here - the main problem is that with 4- or 5-layer macros, this can quickly
go deep and become unwieldy if names start getting too long (as you know me
I of course started with "SpellingLocation" etc :)

Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130508/7002497c/attachment.html>


More information about the cfe-commits mailing list