Newbie question: source locations

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"

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