-
| Asking a question about this instead of filing an issue because I have a feeling I'm misunderstanding how this is supposed to work. I have a C file like this: void test() {
  char buf[8];
  int j = 0;
  for (int i = 0; i < sizeof(buf); i++) {
    buf[j++] = i;
  }
}I run this query: from ForStmt fs
select fs, fs.getAChild*()I get back this: While it's a little hard to read, it should be clear that while it returns the  from AssignExpr ae
select ae, ae.getAChild()Which returns as expected. Is this a bug or am I misunderstanding how  | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
| The problem here is that  What you can do is write your own  StmtParent getAChild(StmtParent p) {
  result = p.(Expr).getAChild()
  or
  result = p.(Stmt).getAChild()
}and then take the transitive reflexive closure of that. | 
Beta Was this translation helpful? Give feedback.
The problem here is that
Expr::getAChildandStmt::getAChildare actually two different predicates. So when you take the transitive closure ofStmt::getAChild, then it will not includeExpr::getAChild.What you can do is write your own
getAChildpredicateand then take the transitive reflexive closure of that.