<div dir="ltr"><div><div style="font-size:13px">Hi all,</div><div style="font-size:13px"><br></div><div style="font-size:13px">I’ve got some questions about the data returned by the Python bindings to clang.</div><div style="font-size:13px"><br></div></div><div>When clang is invoked with “-Xclang -ast-dump -fsyntax-only” to dump the AST for a source file, the output of clang appears to provide much richer output than the Python bindings exposes. I’m guessing this is because the relevant details are deeply embedded in the cursor object returned by the Python API, but I’m not sure where I should be looking for this extra detail.</div><div><br></div><div><div style="font-size:13px">In particular, when clang returns a CXXConstructExpr, the Python API returns CursorKind.CALL_EXPR, which is the same node type returned by a normal function call - so it isn’t possible to differentiate a normal method call from a constructor.</div><div style="font-size:13px"><br></div><div style="font-size:13px">Similarly, when clang returns a MaterializeTemporaryExpr or ImplicitCastExpr, the Python API returns a CursorKind.UNEXPOSED_EXPR. </div><div style="font-size:13px"><br></div><div style="font-size:13px">How do you interrogate the Python API to determine the richer node types that clang is returning?</div><div style="font-size:13px"><br></div><div style="font-size:13px"><div>If it helps, I’ve posted full example code and output in a gist:</div><div><br></div><span style="font-size:small"><a href="https://gist.github.com/freakboy3742/5826ef09789dfba9042e">https://gist.github.com/freakboy3742/5826ef09789dfba9042e</a></span><br><div><br></div><div>This contains three files: </div><div><br></div><div> * a sample.cpp file with a simple class, and a function using that class</div><div> </div><div> * An AST dump of the file provided by clang</div><div><br></div><div> * The AST produced by the Python bindings, generated by walking the tree, printing the node kind, type, return type and spelling, and then doing the same for each child.</div></div><div style="font-size:13px"><br></div><div style="font-size:13px">Yours,</div><div style="font-size:13px">Russ Magee %-)</div></div></div>