I am trying to search for ifStmt
s, which aren't an else if
. To accomplish that, I want to test if the Stmt has a Parent, which is not an ifStmt(hasElse(ifStmt(equals(<myCurrentNode>))))
The following obviously does not work, but I could not find a better solution.
clang-query> m ifStmt(<myMatcherforMyNode>, unless(hasParent(ifStmt(hasElse(ifStmt(equalsBoundNode("ifelse"))))))).bind("ifelse")
Ok just found it out myself by searching the source of clang-tidy:
Just use something like ifStmt(ifStmt().bind("if"), <myMatcherForMyNode>, unless(hasParent(ifStmt(hasElse(ifStmt(equalsBoundNode("if")))))))
.
Also, ifStmt(stmt().bind("if"), <myMatcherForMyNode>, unless(hasParent(ifStmt(hasElse(ifStmt(equalsBoundNode("if")))))))
will do the job