[cfe-dev] libclang - return types of Objective-C methods not returned

Vinay Sajip vinay_sajip at yahoo.co.uk
Fri Sep 9 04:59:35 PDT 2011


The following program, test.m:

@interface MyObject {
}

+ (int) my_cm:(SEL)aSel;
- (double) my_im:(id)anId;

@end

extern int my_f(double d);

produces the following cursors (using recursion in the visitor). The columns are
the spellings of the cursor, the cursor kind, the cursor type kind and the type
kind of the cursor type's return type.

SEL	TypedefDecl	Typedef	Invalid
SEL	TypeRef	Typedef	Invalid
id	TypedefDecl	Typedef	Invalid
id	TypeRef	Typedef	Invalid
Class	TypedefDecl	Typedef	Invalid
Class	TypeRef	Typedef	Invalid
__builtin_va_list	TypedefDecl	Typedef	Invalid
MyObject	ObjCInterfaceDecl	ObjCInterface	Invalid
my_cm:	ObjCClassMethodDecl	Invalid	Invalid
aSel	ParmDecl	Typedef	Invalid
SEL	TypeRef	Typedef	Invalid
my_im:	ObjCInstanceMethodDecl	Invalid	Invalid
anId	ParmDecl	Typedef	Invalid
id	TypeRef	Typedef	Invalid
my_f	FunctionDecl	FunctionProto	Int
d	ParmDecl	Double	Invalid

Note that the return type of my_f is correctly returned as Int, but the
Objective C methods show an Invalid return type.

I also looked at clang_getOverriddenCursors() just in case, but (as expected)
none are returned for the ObjC methods.

Is there some way which I've missed which can be used to get an Objective-C
method's return type?

Thanks,

Vinay Sajip




More information about the cfe-dev mailing list