Search code examples
llvm-clang

ASTContext::getParents() - Ancestors or Parents?


ASTContext::getParents is supposed to return the parents of a given node. My question is how can one AST node have more than one parent?? I suspected that the doc might mean the member function returns the ancestors of a given node, not just the parents and i tested it. sizereturns a size of1` and all the nodes i tested only have one parent.


Solution

  • It's been a couple of years but anyways. I did ask the question on the clang mailing list but the archive link doesn't seem to exist anymore. The parents member function could be parent when it comes to C since in C, AST nodes can't have more than one parent. parents makes sense in C++ where nodes can have more than one parent in the AST. This happens for example with template instantiations and lambdas where a node can end up with more than one parent.