[cfe-dev] Expansion location and spelling location

Manuel Klimek klimek at google.com
Tue May 8 03:14:29 PDT 2012

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.


> 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