[cfe-dev] libclang: Getting ObjCInterfaceDecl cursor from ObjCMessageExpr cursor
Ted Kremenek
kremenek at apple.com
Mon Jan 10 23:56:36 PST 2011
On Jan 8, 2011, at 11:17 AM, Nikita Zhuk <nikita at zhuk.fi> 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.
More information about the cfe-dev
mailing list