[cfe-dev] A Question Regarding hasLHS() and hasRHS() Matchers

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Sat Nov 26 04:23:53 PST 2016


Use expr() instead of anything(). expr() supports binding.

On Sat, Nov 26, 2016 at 1:04 PM Farzad Sadeghi via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> according to the AST Matcher reference, hasRHS and hasLHS should match
> the right-hand-side and left-hand-side of a binary operator.
> first off, the examples in the reference dont work(anymore?) since
> hasLHS() and hasRHS require an argument.
> anyways here are the matchers i used in clang-query:
> binaryOperator(hasLHS(anything()))
> binaryOperator(hasRHS(anything()))
> here are the results:
> /home/bloodstalker/devi/hell4/test.c:8:6: note: "root" binds here
>         if (a || b)
>             ^~~~~~
> 1 match.
> they both return the same thing because the root is the same but
> hasLHS() and hasRHS() and anything() don't support id-binding.
> my question is, how can i match the left--hand-side or right-hand-side
> of a BinaryOperator then?
>
> --
> Farzad Sadeghi
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161126/a5ca642f/attachment.html>


More information about the cfe-dev mailing list