<div dir="ltr"><div style="font-size:12.8000001907349px">I'm using libclang + python bindings to try to extract information about functions and their parameters from a header file. However, the header file I'm working with is incomplete: it's missing many typedefs used in the function declarations. I'm trying to build up a list of all the missing types, but am having some difficulties. <span style="font-size:12.8000001907349px">Here is a reduced example of the problem I'm having:</span></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>void f1(int);</div><div>void f2(bah);</div><div>void f3(int, bah);</div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">'bah' is an undefined type.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">The issue I'm having how to determine if 'bah' is an undefined type. When I dump the tree for the above header, I get this:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>headers/undefined_vs_int.h (TRANSLATION_UNIT)</div><div>  +--f1 (FUNCTION_DECL)</div><div>  |  +-- (PARM_DECL)</div><div>  +--f2 (FUNCTION_DECL)</div><div>  +--f3 (FUNCTION_DECL)</div><div>     +-- (PARM_DECL)</div><div>     +--bah (PARM_DECL)</div></div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">What's odd to me is that 'f2' has no children, but 'f3' does. If I swap the order of 'int' and 'bah' in f3, then it will have no children. So, it seems that the error of not having 'bah' defined will short circuit the parsing of the rest of the function declaration if it comes first in the argument list. But if it comes after a valid type, 'bah' winds up being converted to an integer, and I cannot figure out any way to determine when that occurs. Additionally, if I add more arguments to f3 after 'bah', they will be parsed fine and added to the tree.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">This is throwing me for a loop, as I'm trying to parse a very large header file with a number of types that are undefined (I plan on adding them once I have a collection of exactly what is missing). But right now, it's impossible for me to trust the output I'm getting since it seems to different depending on where the first undefined type is in the argument list.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">FYI, the tree dumping code is this:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px"><div>        print asciitree.draw_tree(tu.cursor,</div><div>                                    lambda n: list(n.get_children()),</div><div>                                    lambda n: "%s (%s)" % (n.spelling or n.displayname, str(n.kind).split(".")[1]))</div><div><br></div><div>Is this a use case for which libclang is not suited?</div><div><br></div><div>Thanks,</div><div><br></div><div>Sean</div></div></div>