[cfe-dev] Problem obtaining the SourceRange of a BinaryOperator

Manuel Klimek klimek at google.com
Mon Apr 28 09:57:25 PDT 2014


On Mon, Apr 28, 2014 at 11:16 AM, Daniel QuiƱones Lopez
<kaos09 at hotmail.com>wrote:

> Hello,
>
> I have a problem when trying to obtain the SourceRange of a BinaryOperator
> which RHS is a null pointer. Having something like "x = Null;", being x a
> pointer type variable, i can get the location of everything but the "Null",
> it seems like it doesn't exists. If I print the ast, the part referred to
> this is:
>
> `-BinaryOperator 0xc750768 <line:7:5,
> /usr/local/bin/../lib/clang/3.4/include/stddef.h:72:18> 'char *' lvalue '='
> | |     |-MemberExpr 0xc750728 <prueba.cpp:7:5> 'char *' lvalue ->x
> 0xc7505b0
> | |     | `-CXXThisExpr 0xc750718 <col:5> 'class X *' this
> | |     `-ImplicitCastExpr 0xc750758
> </usr/local/bin/../lib/clang/3.4/include/stddef.h:72:18> 'char *'
> <NullToPointer>
> | |       `-GNUNullExpr 0xc750748 <col:18> 'int'
>
> But i don't see it clearly. Can someone help me with this?
>

I assume your problem is that Null is a macro in your code... So you'll
have to drill through the expansion / spelling locations to get to the
right point.


>
> Thank you.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140428/5e88c0d2/attachment.html>


More information about the cfe-dev mailing list