[cfe-dev] Clang, Macros and Locations

George Kastrinis george.kastrinis at logicblox.com
Thu Aug 15 12:25:23 PDT 2013


Hey Sam. Thanks for the suggestion.

We finally found a way to handle Declarations by getting the complete
expansion stack (all the locations of macros that are part of the final
result) as well as the include locations.


On Thu, Aug 15, 2013 at 1:10 PM, Sam Parker <S.Parker3 at lboro.ac.uk> wrote:

>  Hi George,
>
> I was having a similar problem with source locations and macros, but I was
> doing source-to-source transformations. I don't know if it will help you,
> but I first expanded all the macros using a RewriteMacrosAction, and that
> gave me valid SourceLocations to rewrite to.
>
> Regards,
> Sam
>
> On 13/08/13 19:12, George Kastrinis wrote:
>
> Hi all,
>
>  We are working on a Clang plugin, and we wan to have a way to uniquely
> identify every declaration in a C++ program. We tried using the following.
> (presumed location start, presumed location end, spelling location start,
> spelling location end, declaration kind)
>
>  But we still have a problem.
>
>  For example, in /usr/include/x86_64-linux-gnu/bits/cmathcalls.h, line
> 101 a macro called _MATHCALL is used. If you look at
> /usr/include/complex.h, line 65 where the macro is defined, you will see
> that the macro uses other macros inside and create two functions (e.g.
> cpowf and __cpowf)
>
>  I tried using spelling locations, presumed locations,
> SourceManager::getExpansionLoc on the spelling location. All give the same
> locations for cpowf and __cpowf.
>
>  Is there any way to achieve what I try to do here?
>
>  Thanks for your time
>
>  --
>
> George Kastrinis
> http://gkastrinis.info/
>
>
> _______________________________________________
> cfe-dev mailing listcfe-dev at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
>


-- 

George Kastrinis
http://gkastrinis.info/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130815/07cc5f9e/attachment.html>


More information about the cfe-dev mailing list