[cfe-dev] matcher acting wierd,imho

Manuel Klimek via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 8 08:50:47 PST 2016


Sam, any ideas whether this might be a dynamic matcher problem?

On Tue, Nov 8, 2016 at 7:48 AM Aaron Ballman <aaron at aaronballman.com> wrote:

> On Tue, Nov 8, 2016 at 5:28 AM, Malcolm Parsons
> <malcolm.parsons at gmail.com> wrote:
> > On 7 November 2016 at 21:11, Aaron Ballman via cfe-dev
> > <cfe-dev at lists.llvm.org> wrote:
> >> ifStmt( allOf( hasDescendant(ifStmt()), hasElse(anything()),
> >> unless(hasAncestor(ifStmt())) ) )
> >>
> >> I think that this does not match the top-level if statement because
> >> hasDescendant(ifStmt()) will not be satisfied -- the top-level if
> >> statement has no sub statements that are also an if statement.
> >
> > hasDescendant != hasChild.
> >
> > It's the hasAncestor that is behaving strangely:
> >
> > clang-query> match ifStmt(hasDescendant(ifStmt()), hasAncestor(ifStmt()))
> >
> > Match #1:
> >
> > ifstmt.c:5:3: note: "root" binds here
> >   if (a == b) {
> >   ^~~~~~~~~~~~~
> > 1 match.
> > clang-query> match ifStmt(hasDescendant(ifStmt()),
> > hasAncestor(ifStmt().bind("ancestor")))
> > 0 matches.
>
> Okay, that is really strange. Adding a .bind() should not alter the
> matches, as far as I'm aware. Manuel or Samuel, can you shed some
> light on this? I think it's a bug.
>
> ~Aaron
>
> >
> > --
> > Malcolm Parsons
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161108/de82c121/attachment.html>


More information about the cfe-dev mailing list