Question

world! I am trying to use libclang to determine the superclass that an Objective-C method belongs to. I have a cursor representing an instance method (CXCursor_ObjCInstanceMethodDecl). When I get the cursor's parent, I get a cursor of kind CXCursor_ObjCImplementationDecl. I need to be able to get the interface cursor from this last cursor in order to determine the method's superclass. Is there a way to do this?

Was it helpful?

Solution

Calling clang_getCanonicalCursor() on the cursor for the @implementation declaration will return the cursor for the @interface declaration. Visiting the children of this cursor will provide access to its superclass reference.

You can also use clang_getOverriddenCursors() on the cursor for the method to determine if it is overriding another from a superclass, protocol, or category.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top