libclang: Getting ObjCInterfaceDecl cursor from ObjCMessageExpr cursor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

libclang: Getting ObjCInterfaceDecl cursor from ObjCMessageExpr cursor

Nikita Zhuk
Hi,

I saw the LLVM developer meeting's presentation of libclang and decided to try it out. The API looks really good and as a ObjC developer I feel much more comfortable using C API instead of clang's internal C++ APIs. So I would like to thank you very much for developing this API.

Now, a question / feature request. When traversing the AST with CXCursors, I encounter CXCursor pointing to a ObjCMessageExpr. Is there any way of getting the cursor which points to the declaration of the receiver interface, equivalent of getReceiverInterface() in the underlying ObjCMessageExpr C++ class? If not (I suppose not - by looking at the CXCursor.cpp), are there any known / recommended ways of traversing ObjC class hierarchies with libclang API, or would this be a useful addition to the API?

Ted Kremenek mentioned in [1] that there are tools using libclang which use ObjC type hierarchy, are these tools public / open source and if so, can you give some pointers to them?

Best regards,
Nikita Zhuk


[1] http://thread.gmane.org/gmane.comp.compilers.clang.devel/11538/focus=11548



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: libclang: Getting ObjCInterfaceDecl cursor from ObjCMessageExpr cursor

Ted Kremenek
On Jan 8, 2011, at 11:17 AM, Nikita Zhuk <[hidden email]> wrote:

> I saw the LLVM developer meeting's presentation of libclang and decided to try it out. The API looks really good and as a ObjC developer I feel much more comfortable using C API instead of clang's internal C++ APIs. So I would like to thank you very much for developing this API.
>
> Now, a question / feature request. When traversing the AST with CXCursors, I encounter CXCursor pointing to a ObjCMessageExpr. Is there any way of getting the cursor which points to the declaration of the receiver interface, equivalent of getReceiverInterface() in the underlying ObjCMessageExpr C++ class? If not (I suppose not - by looking at the CXCursor.cpp), are there any known / recommended ways of traversing ObjC class hierarchies with libclang API, or would this be a useful addition to the API?

It should be possible to get this information by traversing the child CXCursors of the message expression.  While generic, the disadvantage of the CXCursor API is that isn't always obvious.

It might be useful to look at the output of 'c-index-test -test-load-source all test.m', with test.m being source that exhibits different kinds of message expressions.

I personally wouldn't be opposed, however, to adding a convenience API hook for this query.

>
> Ted Kremenek mentioned in [1] that there are tools using libclang which use ObjC type hierarchy, are these tools public / open source and if so, can you give some pointers to them?

I don't know of specific open source tools.  The tool I was referring to in my previous email was Xcode 4, which uses libclang for indexing, code completion, and syntax highlighting.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev