<div dir="ltr">which declRefExpr do you expect to be a child of which other declRefExpr?</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 25, 2016 at 9:40 AM Farzad Sadeghi <<a href="mailto:thabogre@gmail.com">thabogre@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">thank you for the explanation. I do realize that, but that is clearly<br class="gmail_msg">
not the case here.<br class="gmail_msg">
<br class="gmail_msg">
On 11/25/16, Manuel Klimek <<a href="mailto:klimek@google.com" class="gmail_msg" target="_blank">klimek@google.com</a>> wrote:<br class="gmail_msg">
> On Fri, Nov 25, 2016 at 9:24 AM Farzad Sadeghi via cfe-dev <<br class="gmail_msg">
> <a href="mailto:cfe-dev@lists.llvm.org" class="gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
>> for the source code below:<br class="gmail_msg">
>> short int test16(int a, int b)<br class="gmail_msg">
>> {<br class="gmail_msg">
>> short int sum;<br class="gmail_msg">
>> short unsigned int sumus;<br class="gmail_msg">
>> sum = a + b;<br class="gmail_msg">
>> sumus = a + b;<br class="gmail_msg">
>><br class="gmail_msg">
>> return sum;<br class="gmail_msg">
>> }<br class="gmail_msg">
>> with AST:<br class="gmail_msg">
>> |-FunctionDecl 0x4e52920 <line:821:1, line:829:1> line:821:11 test16<br class="gmail_msg">
>> 'short (int, int)'<br class="gmail_msg">
>> | |-ParmVarDecl 0x4e527d8 <col:18, col:22> col:22 used a 'int'<br class="gmail_msg">
>> | |-ParmVarDecl 0x4e52848 <col:25, col:29> col:29 used b 'int'<br class="gmail_msg">
>> | `-CompoundStmt 0x4e52d60 <line:822:1, line:829:1><br class="gmail_msg">
>> | |-DeclStmt 0x4e52a48 <line:823:2, col:15><br class="gmail_msg">
>> | | `-VarDecl 0x4e529e8 <col:2, col:12> col:12 used sum 'short'<br class="gmail_msg">
>> | |-DeclStmt 0x4e52ad0 <line:824:2, col:26><br class="gmail_msg">
>> | | `-VarDecl 0x4e52a70 <col:2, col:21> col:21 used sumus 'unsigned<br class="gmail_msg">
>> short'<br class="gmail_msg">
>> | |-BinaryOperator 0x4e52bd0 <line:825:2, col:12> 'short' '='<br class="gmail_msg">
>> | | |-DeclRefExpr 0x4e52ae8 <col:2> 'short' lvalue Var 0x4e529e8 'sum'<br class="gmail_msg">
>> 'short'<br class="gmail_msg">
>> | | `-ImplicitCastExpr 0x4e52bb8 <col:8, col:12> 'short' <IntegralCast><br class="gmail_msg">
>> | | `-BinaryOperator 0x4e52b90 <col:8, col:12> 'int' '+'<br class="gmail_msg">
>> | | |-ImplicitCastExpr 0x4e52b60 <col:8> 'int' <LValueToRValue><br class="gmail_msg">
>> | | | `-DeclRefExpr 0x4e52b10 <col:8> 'int' lvalue ParmVar<br class="gmail_msg">
>> 0x4e527d8 'a' 'int'<br class="gmail_msg">
>> | | `-ImplicitCastExpr 0x4e52b78 <col:12> 'int' <LValueToRValue><br class="gmail_msg">
>> | | `-DeclRefExpr 0x4e52b38 <col:12> 'int' lvalue ParmVar<br class="gmail_msg">
>> 0x4e52848 'b' 'int'<br class="gmail_msg">
>> | |-BinaryOperator 0x4e52ce0 <line:826:2, col:14> 'unsigned short' '='<br class="gmail_msg">
>> | | |-DeclRefExpr 0x4e52bf8 <col:2> 'unsigned short' lvalue Var<br class="gmail_msg">
>> 0x4e52a70 'sumus' 'unsigned short'<br class="gmail_msg">
>> | | `-ImplicitCastExpr 0x4e52cc8 <col:10, col:14> 'unsigned short'<br class="gmail_msg">
>> <IntegralCast><br class="gmail_msg">
>> | | `-BinaryOperator 0x4e52ca0 <col:10, col:14> 'int' '+'<br class="gmail_msg">
>> | | |-ImplicitCastExpr 0x4e52c70 <col:10> 'int' <LValueToRValue><br class="gmail_msg">
>> | | | `-DeclRefExpr 0x4e52c20 <col:10> 'int' lvalue ParmVar<br class="gmail_msg">
>> 0x4e527d8 'a' 'int'<br class="gmail_msg">
>> | | `-ImplicitCastExpr 0x4e52c88 <col:14> 'int' <LValueToRValue><br class="gmail_msg">
>> | | `-DeclRefExpr 0x4e52c48 <col:14> 'int' lvalue ParmVar<br class="gmail_msg">
>> 0x4e52848 'b' 'int'<br class="gmail_msg">
>> | `-ReturnStmt 0x4e52d48 <line:828:2, col:9><br class="gmail_msg">
>> | `-ImplicitCastExpr 0x4e52d30 <col:9> 'short' <LValueToRValue><br class="gmail_msg">
>> | `-DeclRefExpr 0x4e52d08 <col:9> 'short' lvalue Var 0x4e529e8<br class="gmail_msg">
>> 'sum' 'short'<br class="gmail_msg">
>> when i run the below matcher on clang-query:<br class="gmail_msg">
>> match declRefExpr(hasAncestor(declRefExpr()))<br class="gmail_msg">
>> i get no matches, while in the AST it clearly says that there are such<br class="gmail_msg">
><br class="gmail_msg">
> nodes. so I was wondering what could be causing this.<br class="gmail_msg">
>><br class="gmail_msg">
><br class="gmail_msg">
> Perhaps we can make the printing easier to read here:<br class="gmail_msg">
> -a<br class="gmail_msg">
> ||-b<br class="gmail_msg">
> |`-c<br class="gmail_msg">
> does not mean that c is a child of b, it means (if I'm not mistaken) that c<br class="gmail_msg">
> is the last child of a, but both b and a are equally children of a.<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
>> --<br class="gmail_msg">
>> Farzad Sadeghi<br class="gmail_msg">
>> _______________________________________________<br class="gmail_msg">
>> cfe-dev mailing list<br class="gmail_msg">
>> <a href="mailto:cfe-dev@lists.llvm.org" class="gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a><br class="gmail_msg">
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br class="gmail_msg">
>><br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Farzad Sadeghi<br class="gmail_msg">
</blockquote></div>