[cfe-dev] Newbie question: source locations

Manuel Klimek klimek at google.com
Mon Nov 3 01:04:07 PST 2014


On Fri Oct 31 2014 at 2:10:31 PM Christian Convey <
christian.convey at gmail.com> wrote:

> I'm dealing with the clang AST for the first time, and I'm having
> trouble understanding from the doxygen docs how the various flavors of
> source locations relate to each other.  Can anyone point me to a good
> explanation?
>
> I *think* I'm pretty clear on spelling locations.  But I'm definitely
> confused about "presumed location" and "getImmediateExpansionRange"
>

Yea, those are tricky - I wanted to write a tutorial there for a while, but
never got around to it; I tried to cover some of that in my talk on the
clang AST you can view at
http://clang.llvm.org/docs/IntroductionToTheClangAST.html (although it
doesn't cover presumed locations).

I also have a patch that rsmith has bikeshed to death (which means I've
stopped working on it after a while, perhaps I should revive it) which
enables you to get nice output about source locations like this:
http://pastebin.com/SzjYDDiu

If you look at that it gives you a nice example on how expansion and
spelling locations work, and why there are different levels. The
"immediate" functions always go one level either towards the spelling or
the expansion. Note how it is generally a tree and not a single chain.

Presumed locations are simply the expansion locations modified by the #line
directives (which you for example find in preprocessed files).

Cheers,
/Manuel





> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141103/f7fed831/attachment.html>


More information about the cfe-dev mailing list