libclang - access to function parameter types

It appears that function parameter types are not accessible via the libclang API
- can someone confirm this? I can access the return type and parameter types via
declarations using child nodes of the declaration cursor (e.g. ParmDecl), but if
handed a CXType corresponding to a pointer to a function with prototype, how can
you get at the parameter types of the function?

Thanks,

Vinay Sajip

It appears that function parameter types are not accessible via the libclang API
- can someone confirm this? I can access the return type and parameter types via
declarations using child nodes of the declaration cursor (e.g. ParmDecl), but if
handed a CXType corresponding to a pointer to a function with prototype, how can
you get at the parameter types of the function?

There is no way currently; there should be something like 'unsigned clang_getFunctionTypeNumParams(CXType)' and 'CXType clang_getFunctionTypeParam(CXType, unsigned index)'

Argyrios Kyrtzidis <kyrtzidis@...> writes:

There is no way currently; there should be something like 'unsigned
clang_getFunctionTypeNumParams(CXType)' and 'CXType

clang_getFunctionTypeParam(CXType,

unsigned index)'

I've already implemented this in my branch at GitHub - vsajip/clang: Improvements and bug-fixes for libclang. See the develop branch for these.
as follows:

int clang_getFunctionArgumentCount(CXType);
CXType clang_getFunctionArgumentType(CXType, unsigned);

The reasoning for the int return from the former is as an error return of -1 in
case the type passed in is not a function with prototype.

I've also implemented exposing constant arrays (as mentioned on issue 9348) using

int clang_getArraySize(CXType); // returns -1 for invalid type
CXType clang_getArrayElementType(CXType);

as well as exposing the type using a new constant CXType_ConstantArray.

Furthermore, I've implemented accessing EnumConstantDecl values as well as
declaration attributes (such as inline) using a function

int clang_getCursorValue(CXCursor);

Might any of these be of any interest for merging into trunk ... ?

Regards,

Vinay Sajip

Argyrios Kyrtzidis <kyrtzidis@...> writes:

There is no way currently; there should be something like 'unsigned
clang_getFunctionTypeNumParams(CXType)' and 'CXType

clang_getFunctionTypeParam(CXType,

unsigned index)'

I've already implemented this in my branch at GitHub - vsajip/clang: Improvements and bug-fixes for libclang. See the develop branch for these.
as follows:

int clang_getFunctionArgumentCount(CXType);
CXType clang_getFunctionArgumentType(CXType, unsigned);

The reasoning for the int return from the former is as an error return of -1 in
case the type passed in is not a function with prototype.

I've also implemented exposing constant arrays (as mentioned on issue 9348) using

int clang_getArraySize(CXType); // returns -1 for invalid type
CXType clang_getArrayElementType(CXType);

as well as exposing the type using a new constant CXType_ConstantArray.

Furthermore, I've implemented accessing EnumConstantDecl values as well as
declaration attributes (such as inline) using a function

int clang_getCursorValue(CXCursor);

Might any of these be of any interest for merging into trunk ... ?

Definitely; please post in cfe-commits with a patch for review.

Argyrios Kyrtzidis <kyrtzidis@...> writes:

> Might any of these be of any interest for merging into trunk ... ?

Definitely; please post in cfe-commits with a patch for review.

Okay, done as three separate patches. Checking on pipermail via the web
indicates that the attached patches have been "scrubbed", but AFAICT the links
in the mails to the attachments do seem to work.

Regards,

Vinay Sajip

Argyrios Kyrtzidis <kyrtzidis@...> writes:

Might any of these be of any interest for merging into trunk ... ?

Definitely; please post in cfe-commits with a patch for review.

Okay, done as three separate patches. Checking on pipermail via the web
indicates that the attached patches have been "scrubbed", but AFAICT the links
in the mails to the attachments do seem to work.

The patches are attached, I'll take a look at them soon(ish).