[cfe-dev] Exporting Clang AST
Bhargava Shastry via cfe-dev
cfe-dev at lists.llvm.org
Sun Sep 27 05:27:41 PDT 2015
I am trying to export clang AST to a file, recreating the tree structure
in a suitable format e.g., xml/json. I am using the RecursiveASTVisitor
Question: What is the invariant for establishing parent-child
relationship between AST nodes? I see that one potential invariant is
``If two AST nodes have the same DeclContext pointer, then they are in
the same scope i.e., siblings or parent-children.`` Is there a stronger
invariant that establishes parent-child relationship? Sadly, the Decl
class doesn't have a getParent() that returns its parent AST node.
Also, is there a generic way I could ask the same question for nodes of
Stmt and Type classes?
P.S. I tried to infer the invariant by skimming through ASTDumper code.
But, ASTDumper invents custom traversal different from what RAV
provides, so it's non-trivial to map logic from/to two different models.
Bhargava Shastry <bshastry at sec.t-labs.tu-berlin.de>
Security in Telecommunications
TU Berlin / Telekom Innovation Laboratories
Ernst-Reuter-Platz 7, Sekr TEL 17 / D - 10587 Berlin, Germany
phone: +49 30 8353 58235
More information about the cfe-dev