[cfe-dev] Missing features in libclang: complex element type, "unexposed" function pointer types in structs, __asm__ and calling convention attributes
Joe Groff
arcata at gmail.com
Sat Nov 19 13:03:21 PST 2011
Hi everyone. I'm trying to write an FFI bindings generator using the cursor
visitor functionality in libclang. Overall the API is nice and clean, but
it looks like it's missing a few pieces. I wanted to ask whether these were
on anyone's to-do list before looking into adding them myself, and check
that I'm not just doing it wrong. In particular, I'm missing the following
functionality:
- There's no way to get the element type from a Complex-kind CXType. There
was a thread about incorporating this functionality by generalizing the
clang_getArrayElementType function:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110926/046899.html
Is this being worked on?
- Function pointer fields in structs or unions show up as pointers to
"Unexposed"-kind CXTypes, although you can still visit their parameter
child nodes and access the return type from clang_getResultType. Given this
C snippet:
---
typedef int (*noproto_t)();
typedef int (*proto_t)(int x);
typedef int (*variadic_t)(int x, ...);
struct bar {
int (*noproto)();
int (*proto)(int x);
int (*variadic)(int x, ...);
};
---
The noproto_t, proto_t, and variadic_t typedef types show up as pointers to
FunctionNoProto and FunctionProto types as you'd expect, but the types of
the noproto, proto, and variadic fields of the bar struct show up as
pointers to Unexposed (although the underlying function type information
appears to still be accessible). Is this a bug or intended behavior?
- To be able to accurately bind to some APIs I need to be able to know the
__asm__("symbolname"), if any. It looks like this currently appears as an
UnexposedAttr cursor kind during traversal. Is there any way to access the
asm name through that cursor? I also couldn't find any immediately obvious
way to visit calling convention attributes (__attribute__((stdcall)),
__attribute__((naked)) etc.) Am I missing something there?
That's all for now. Thanks for the help!
-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111119/1c441935/attachment.html>
More information about the cfe-dev
mailing list