clang_getCursorUSR : reverse?

Hello

I might be misunderstanding clang_getCursorUSR. I believe it’s purpose is to facilitate comparing entities across translation units, but Im not quite sure how to exactly go about the comparison.

Is the client program supposed to recursively descend (visitChildren) the second translation unit, testing clang_getCursorUSR on each cursor against the cursor from the first translation unit it wants to find?

is there a way to keep this functionality “inside” the libclang api rather than have the client be responsible for it?

eg
since there is a function
CXString clang_getCursorUSR( CXCursor );

should there be a function

CXCursor clang_getCursorFromUSR( CXString );

??

P.S. what piqued my curiosity is the libclang lecture found here:
http://devimages.apple.com/llvm/videos/Libclang.mov

Hello

I might be misunderstanding clang_getCursorUSR. I believe it’s purpose is to facilitate comparing entities across translation units, but Im not quite sure how to exactly go about the comparison.

Is the client program supposed to recursively descend (visitChildren) the second translation unit, testing clang_getCursorUSR on each cursor against the cursor from the first translation unit it wants to find?

Yes, that’s one way. The assumption that libclang makes is that there is some external database that will help perform mappings across

is there a way to keep this functionality “inside” the libclang api rather than have the client be responsible for it?

eg
since there is a function
CXString clang_getCursorUSR( CXCursor );

should there be a function

CXCursor clang_getCursorFromUSR( CXString );

??

I think that would make a great addition. It’s going to require writing the equivalent of a demangler for USRs (mapping from USRs to entity names and such) along with a localized search to find matching USRs, but it would be really useful.

  • Doug