[cfe-dev] Getting the class name for a category in libclang

David Chisnall csdavec at swan.ac.uk
Fri Oct 29 13:24:15 PDT 2010


On 29 Oct 2010, at 21:19, Ted Kremenek wrote:

> 
> On Oct 29, 2010, at 12:46 PM, David Chisnall wrote:
> 
>>> When visiting the children of that cursor, I believe you should see a class reference to the @interface for 'Foo'.  You should be able to query the class name that way.  Does this work?  It's a little indirect, and possibly worthy of a wrapper API.
>> 
>> 
>> This sometimes works.  If there is an @implementation decl for the class visible, then there is an ObjCClassRef child.  If there is not, however, then the only children are the methods.  In the underlying APIs, it would simply be a call to ->getClassInterface() to get the interface.
> 
> I'm not seeing this.  This is what I see using c-index-test:
> 
> $ cat t.m
> @interface Foo @end
> @protocol Bar @end
> @interface Foo (Bar) @end

That is not the same as what I said.  I have:

@interface Foo @end
@implementation Foo (Bar)
- (void)bar {}
@end

Here, I am only able to get from the category implementation to the class interface if I also have a class implementation in the same compilation unit.  If I add this, then it works:

@implementation Foo @end

David



More information about the cfe-dev mailing list