<div dir="ltr">On Fri, May 17, 2013 at 6:27 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">+1 to both suggestions. For expansion locations, it'd be wonderful to see the actual macro invocation. For spelling locations, it'd be great to see the macro body if it's short enough, but even the first token of the macro would be really helpful.<br>
</blockquote><div><br></div><div style>I'll see what I can hack up. </div><div style><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
And yes, without filenames this will probably be very difficult to read for a real source file with many transitively-included headers. Last-path-component would help a lot.<br></blockquote><div><br></div><div style>For the file locations I just use the normal location printing, so the filename gets included - the output I pasted is from a test that uses unnamed buffers...</div>
<div style><br></div><div style>Cheers,</div><div style>/Manuel</div><div style> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Jordan<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On May 17, 2013, at 4:20 , Kim Gräsman <<a href="mailto:kim.grasman@gmail.com">kim.grasman@gmail.com</a>> wrote:<br>
<br>
> Hi Manuel,<br>
><br>
> I think the new structure works even with the intimidating location in<br>
> the example.<br>
><br>
> I wonder if it would help even more if you included a source text<br>
> fragment from every location?<br>
><br>
> I know I would use this to snapshot where a given location is when<br>
> doing AST traversals, and I think more context makes it easier to find<br>
> my bearings.<br>
><br>
> Why are there leading colons in all line/col dumps? Should there be a<br>
> leading filename/file ID?<br>
><br>
> Thanks,<br>
> - Kim<br>
><br>
> On Fri, May 17, 2013 at 11:43 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
>> I played around a bit after trying to understand Argyrios' adaptions for<br>
>> makeFileCharRange, and came up with this:<br>
>><br>
>> Pastebin:<br>
>> <a href="http://pastebin.com/g4ny0vbq" target="_blank">http://pastebin.com/g4ny0vbq</a><br>
>><br>
>> Pasted into mail (will probalby not format well in most mail programs):<br>
>> Loc<br>
>> |-Expansion<br>
>> | |-ExpansionStart<br>
>> | | |-ExpansionStart<br>
>> | | | |-ExpansionStart :4:1,<br>
>> | | | |-ExpansionEnd   :4:16,<br>
>> | | | `-Spelling       :3:16,<br>
>> | | |-ExpansionEnd<br>
>> | | | |-ExpansionStart :4:1,<br>
>> | | | |-ExpansionEnd   :4:16,<br>
>> | | | `-Spelling       :3:19,<br>
>> | | `-Spelling       :2:14,<br>
>> | |-ExpansionEnd<br>
>> | | |-ExpansionStart<br>
>> | | | |-ExpansionStart :4:1,<br>
>> | | | |-ExpansionEnd   :4:16,<br>
>> | | | `-Spelling       :3:16,<br>
>> | | |-ExpansionEnd<br>
>> | | | |-ExpansionStart :4:1,<br>
>> | | | |-ExpansionEnd   :4:16,<br>
>> | | | `-Spelling       :3:19,<br>
>> | | `-Spelling       :2:17,<br>
>> | `-Spelling       :1:14,<br>
>> `-Spelling<br>
>>  |-Expansion<br>
>>  | |-ExpansionStart<br>
>>  | | |-ExpansionStart :4:1,<br>
>>  | | |-ExpansionEnd   :4:16,<br>
>>  | | `-Spelling       :3:16,<br>
>>  | |-ExpansionEnd<br>
>>  | | |-ExpansionStart :4:1,<br>
>>  | | |-ExpansionEnd   :4:16,<br>
>>  | | `-Spelling       :3:19,<br>
>>  | `-Spelling       :2:16,<br>
>>  `-Spelling<br>
>>    |-Expansion<br>
>>    | |-ExpansionStart :4:1,<br>
>>    | |-ExpansionEnd   :4:16,<br>
>>    | `-Spelling       :3:18,<br>
>>    `-Spelling<br>
>>      |-Expansion<br>
>>      | |-ExpansionStart<br>
>>      | | |-ExpansionStart<br>
>>      | | | |-ExpansionStart :4:3,<br>
>>      | | | |-ExpansionEnd   :4:15,<br>
>>      | | | `-Spelling       :3:16,<br>
>>      | | |-ExpansionEnd<br>
>>      | | | |-ExpansionStart :4:3,<br>
>>      | | | |-ExpansionEnd   :4:15,<br>
>>      | | | `-Spelling       :3:19,<br>
>>      | | `-Spelling       :2:14,<br>
>>      | |-ExpansionEnd<br>
>>      | | |-ExpansionStart<br>
>>      | | | |-ExpansionStart :4:3,<br>
>>      | | | |-ExpansionEnd   :4:15,<br>
>>      | | | `-Spelling       :3:16,<br>
>>      | | |-ExpansionEnd<br>
>>      | | | |-ExpansionStart :4:3,<br>
>>      | | | |-ExpansionEnd   :4:15,<br>
>>      | | | `-Spelling       :3:19,<br>
>>      | | `-Spelling       :2:17,<br>
>>      | `-Spelling       :1:14,<br>
>>      `-Spelling<br>
>>        |-Expansion<br>
>>        | |-ExpansionStart<br>
>>        | | |-ExpansionStart :4:3,<br>
>>        | | |-ExpansionEnd   :4:15,<br>
>>        | | `-Spelling       :3:16,<br>
>>        | |-ExpansionEnd<br>
>>        | | |-ExpansionStart :4:3,<br>
>>        | | |-ExpansionEnd   :4:15,<br>
>>        | | `-Spelling       :3:19,<br>
>>        | `-Spelling       :2:16,<br>
>>        `-Spelling<br>
>>          |-Expansion<br>
>>          | |-ExpansionStart :4:3,<br>
>>          | |-ExpansionEnd   :4:15,<br>
>>          | `-Spelling       :3:18,<br>
>>          `-Spelling<br>
>>            |-Expansion<br>
>>            | |-ExpansionStart<br>
>>            | | |-ExpansionStart :4:7,<br>
>>            | | |-ExpansionEnd   :4:13,<br>
>>            | | `-Spelling       :2:14,<br>
>>            | |-ExpansionEnd<br>
>>            | | |-ExpansionStart :4:7,<br>
>>            | | |-ExpansionEnd   :4:13,<br>
>>            | | `-Spelling       :2:17,<br>
>>            | `-Spelling       :1:14,<br>
>>            `-Spelling<br>
>>              |-Expansion<br>
>>              | |-ExpansionStart :4:7,<br>
>>              | |-ExpansionEnd   :4:13,<br>
>>              | `-Spelling       :2:16,<br>
>>              `-Spelling<br>
>>                |-Expansion<br>
>>                | |-ExpansionStart<br>
>>                | | |-ExpansionStart :4:9,<br>
>>                | | |-ExpansionEnd   :4:12,<br>
>>                | | `-Spelling       :2:14,<br>
>>                | |-ExpansionEnd<br>
>>                | | |-ExpansionStart :4:9,<br>
>>                | | |-ExpansionEnd   :4:12,<br>
>>                | | `-Spelling       :2:17,<br>
>>                | `-Spelling       :1:14,<br>
>>                `-Spelling<br>
>>                  |-Expansion<br>
>>                  | |-ExpansionStart :4:9,<br>
>>                  | |-ExpansionEnd   :4:12,<br>
>>                  | `-Spelling       :2:16,<br>
>>                  `-Spelling       :4:11<br>
>><br>
>><br>
>> On Wed, May 8, 2013 at 8:49 PM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
>>><br>
>>> On Wed, May 8, 2013 at 6:42 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>><br>
>>>> On Wed, May 8, 2013 at 5:36 PM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>
>>>>><br>
>>>>> In preparation for some docs on source locations I want to write I came<br>
>>>>> up<br>
>>>>> with the little helper method that visualizes source locations as a<br>
>>>>> tree.<br>
>>>>> This is especially helpful when you have many nested levels of macro<br>
>>>>> expansions.<br>
>>>>><br>
>>>>> Example output:<br>
>>>>> (SP=(:6:14),<br>
>>>>> EX=(SP=(:2:14),<br>
>>>>>     ES=(:6:8),<br>
>>>>>     EE=(:6:15)))<br>
>>>>><br>
>>>>> SP = spelling<br>
>>>>> EX = expansion (if there's only a single location)<br>
>>>>> ES/EE = expansion start, expansion end (in case there's a range)<br>
>>>>><br>
>>>>> Feel free to bikeshed about the details :D<br>
>>>><br>
>>>><br>
>>>> Two high-level questions unrelated to the code itself:<br>
>>>><br>
>>>> 1) Should we visualize these trees in roughly the same tree-ish syntax as<br>
>>>> AST trees? Or is it useful to visualize them on a single line *inside* the<br>
>>>> AST tree?<br>
>>><br>
>>><br>
>>> I'm all for bike shed color ideas: can you create a paste with how you<br>
>>> want it to look? (I tried a few things, and they all looked bad - I'm no<br>
>>> good at that :P)<br>
>>><br>
>>>><br>
>>>> 2) Is there a way to make this part of the testing of source locations<br>
>>>> which is currently done mostly through c-index-test's testing of the writing<br>
>>>> out of cursor details from libclang?<br>
>>><br>
>>><br>
>>> Not sure - I really want a format that's for users; I'd be happy to create<br>
>>> something more machine-readable (JSON for example), so we can use it in<br>
>>> tests, though.<br>
>>><br>
>>>> One nit-picky detail: please don't use the initialisms.... At least, not<br>
>>>> *these*. I see SP, EX, and ES in this syntax and I think "wait, is this a<br>
>>>> stack machine asm chunk?? some other weird assembly language?" before my<br>
>>>> mind returns to sanity. ;]<br>
>>><br>
>>><br>
>>> Just tell me what to use :) I don't have strong feelings about anything<br>
>>> here - the main problem is that with 4- or 5-layer macros, this can quickly<br>
>>> go deep and become unwieldy if names start getting too long (as you know me<br>
>>> I of course started with "SpellingLocation" etc :)<br>
>>><br>
>>> Cheers,<br>
>>> /Manuel<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
>><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br></div></div>