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

Ted Kremenek kremenek at apple.com
Fri Oct 29 12:05:17 PDT 2010


On Oct 29, 2010, at 11:48 AM, David Chisnall wrote:

> Hi,
> 
> I'm trying to build an index using libclang, but there doesn't appear to be any way of getting the class name for a cursor representing an Objective-C category, other than to generate and then parse the USR.  Am I missing something, or is this missing functionality?  

Hi David,

Is clang_getCursorSpelling() not sufficient for this case?

FYI, the USRs should be viewed as opaque strings.  You should never parse them.  They are designed to be changed at any time for purposes of efficiency, etc.  They are really designed to just be unique keys.

> 
> If it's missing, does anyone have any thoughts about the correct way to expose this?  My initial expectation was that the semantic parent for a category should be the class, but there are a number of cases where this quickly becomes nonintuitive.  Should there be a dedicated function for getting the class name from a category declaration?

I don't believe we need a special API for this.  I believe that all of the information is there.  If you find that it is cumbersome, however, we can evaluate whether it makes sense to add additional APIs.



More information about the cfe-dev mailing list