[cfe-dev] matcher acting wierd,imho
Malcolm Parsons via cfe-dev
cfe-dev at lists.llvm.org
Tue Nov 8 02:28:41 PST 2016
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.
--
Malcolm Parsons
More information about the cfe-dev
mailing list