[cfe-dev] SourceLocation and offsets

Sebastian Redl sebastian.redl at getdesigned.at
Tue Sep 21 15:44:08 PDT 2010


Hi,

Trying to verify my knowledge of how the SourceManager works here.

It is my understanding that offsets are actually completely arbitrary: any given source buffer has a starting offset, and the buffer's contents are offset from there, but the order of source buffers in the global offset is pretty much completely arbitrary. This means that I could reorder the SLocEntries in SourceManager (shuffle the vector that holds them and recompute the starting offsets) and as long as I hunt down every SourceLocation and adjust its offset appropriately, nothing has changed.

Also, I'm trying to determine the exact meaning of the MacroIDBit in SourceLocation. It appears to me that it is a simple cache. If I were to look up the SLocEntry for a SourceLocation, am I guaranteed that Loc.isMacroID() == SLE.isInstantiation()? Because if that isn't correct, the difference is too subtle for me to understand.

Sebastian



More information about the cfe-dev mailing list