1

I am trying to search for ifStmts, 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")
Fabian Keßler
  • 563
  • 3
  • 12

1 Answers1

2

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

Fabian Keßler
  • 563
  • 3
  • 12