[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] A Question Regarding hasLHS() and hasRHS() Matchers
From:       Manuel Klimek via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2016-11-26 12:23:53
Message-ID: CAOsfVvnvkfd=9dT73Haejrzrx6jgp08JNQV1TKaeLqEpZOK=EA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

On Sat, Nov 26, 2016 at 1:04 PM Farzad Sadeghi via cfe-dev <
cfe-dev@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@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>

[Attachment #5 (text/html)]

<div dir="ltr">Use expr() instead of anything(). expr() supports \
binding.</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 26, 2016 at \
1:04 PM Farzad Sadeghi via cfe-dev &lt;<a \
href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex">according to the AST Matcher \
reference, hasRHS and hasLHS should match<br class="gmail_msg"> the right-hand-side \
and left-hand-side of a binary operator.<br class="gmail_msg"> first off, the \
examples in the reference dont work(anymore?) since<br class="gmail_msg"> hasLHS() \
and hasRHS require an argument.<br class="gmail_msg"> anyways here are the matchers i \
used in clang-query:<br class="gmail_msg"> binaryOperator(hasLHS(anything()))<br \
class="gmail_msg"> binaryOperator(hasRHS(anything()))<br class="gmail_msg">
here are the results:<br class="gmail_msg">
/home/bloodstalker/devi/hell4/test.c:8:6: note: &quot;root&quot; binds here<br \
class="gmail_msg">  if (a || b)<br class="gmail_msg">
                  ^~~~~~<br class="gmail_msg">
1 match.<br class="gmail_msg">
they both return the same thing because the root is the same but<br \
class="gmail_msg"> hasLHS() and hasRHS() and anything() don&#39;t support \
id-binding.<br class="gmail_msg"> my question is, how can i match the left--hand-side \
or right-hand-side<br class="gmail_msg"> of a BinaryOperator then?<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"> </blockquote></div>


[Attachment #6 (text/plain)]

_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic