I am currently building a parser for C++ code using the clang C API. The parser will process a header file and generate a list of defined and missing symbols for it (it ignores include directives, so it will parse strictly the contents of the header). My problem is, if I have a typedef
for a function pointer which takes an argument of an undefined type, such as:
typedef SOME_TYPE (* funcPtrName)(SOME_UNDEF_TYPE x);
the AST parses SOME_TYPE
as the typedef instead of funcPtrName
. If I replace SOME_UNDEF_TYPE
with int
, it parses funcPtrName
correctly.
I thought I could use clang_tokenize
to get all the tokens for the cursor and manually get the function pointer name, but calling clang_getCursorExtent
on the cursor pointing to the typedef does not work correctly (the range returned is 0,0).
Do you know any way around this issue?