[cfe-dev] Expansion location and spelling location

Volodymyr Sapsai vsapsai at gmail.com
Sun May 13 15:48:40 PDT 2012

On Tue, May 8, 2012 at 1:14 PM, Manuel Klimek <klimek at google.com> wrote:
> On Sat, May 5, 2012 at 1:36 AM, Volodymyr Sapsai <vsapsai at gmail.com> wrote:
>> Hi,
>> I'd like to ask about the difference between expansion and spelling locations.
>> For example, if I have code
>> #define MACRO_INC "tests/indirect.h"
>> #include MACRO_INC
>> and I am in PPCallbacks::FileChanged() method
>> then expansion location is
>> #define MACRO_INC "tests/indirect.h"
>>                  ^
>> #include MACRO_INC
>> and spelling location is
>> #define MACRO_INC "tests/indirect.h"
>> #include MACRO_INC
>>         ^
>> Am I right?
> I think this is exactly reverted :) The spelling location is where the
> user spelled the *code* (in this case the code is "tests/indicrect.h",
> the expansion location is where the macro name is written.
> Cheers,
> /Manuel

Thanks. I've played a little bit with different locations and now
understand the difference.

Volodymyr Sapsai

>> Some more details for my problem. In PPCallbacks::FileChanged(loc, ...) is used
>> SourceManager()->getPresumedLoc(loc).getIncludeLoc() and for this includeLoc
>> earlier I received "tests/indirect.h"\n#include MACRO_INC\n but now I
>> receive MACRO_INC\n. Also in SourceManager documentation is written
>>> Note that a presumed location is always given as the expansion point of an
>>> expansion location, not at the spelling location.
>> So I want to clarify if getPresumedLoc() incorrectly returns spelling location
>> or I don't understand what does spelling location mean.
>> Thanks,
>> Volodymyr Sapsai
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list