[cfe-dev] RFC: What does this matcher mean to you?

Manuel Klimek klimek at google.com
Thu May 23 02:41:51 PDT 2013


For clarification: the problem is less "whether it matches", but for which
matches you get callbacks with what bound nodes.

The forEachDescendant(... .bind("declType")) part in the matcher on its own
will result in a callback for each found declType child, with the node
bound to "declType".

The question is: given that there are multiple matches for
forEachDescendant, what is the behavior of the has(...
equalsBoundNode("declType")) part:
How many callbacks with which bound nodes do you expect?

Cheers,
/Manuel



On Tue, May 21, 2013 at 7:35 PM, Gábor Kozár <kozargabor at gmail.com> wrote:

> I would expect it the equalsBoundNode("declType") to either:
>  - raise an error (assertion failure or exception) or
>  - check all nodes bound to "declType", and return true if any of them is
> equal
>
> Perhaps different variants could be introduced with both behaviors? For
> example, equalsBoundNode(string) would only work if there is exactly one
> node bound to the specified name, while equalsAnyBoundNode(string) would
> look for equality in any node bound to the specified name.
>
>
> 2013/5/21 Vane, Edwin <edwin.vane at intel.com>
>
> We're trying to determine the semantics of the proposed new
>> 'equalsBoundNode()' matcher. Before I present the aforementioned matcher
>> expression let me illustrate what this new matcher does. Given that you've
>> bound a node earlier in a matcher expression with a name "X",
>> equalsBoundNode("X") allows you to refer back to that bound node and test
>> for identity. For example, here's a matcher finding VarDecl's where the
>> type matches the initializer type:
>>
>> varDecl(hasType(qualType().bind("type")),
>>
>>  hasInitializer(ignoringParenImpCasts(hasType(qualType(equalsBoundNode("type"))))))));
>>
>> Semantics get more interesting where forEach*() matchers are concerned.
>> So this is where I ask: What would you expect the following matcher to do?
>> How would you expect it to behave?
>>
>>     functionDecl(
>>       forEachDescendant(
>>         ifStmt(
>>           forEachDescendant(
>>             varDecl(hasType(qualType().bind("declType")))
>>           )
>>         )
>>       ),
>>       has(compoundStmt(has(
>>         callExpr(
>>           callee(
>>             functionDecl(
>>               returns(qualType(equalsBoundNode("declType")))
>>             )
>>           )
>>         )
>>       )))
>>     );
>>
>>
>> --
>> Edwin Vane
>>   Software Developer
>>   Intel of Canada, Inc.
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
>
> _______________________________________________
> 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/20130523/f2996cd9/attachment.html>


More information about the cfe-dev mailing list