[cfe-users] Getting the class name described by a CXCursor

Lucas Soltic lucas.soltic at orange.fr
Thu Jan 2 08:43:43 PST 2014


Hello,

I’m using libclang and I get various CXCursor objects while parsing (with the visitor API, see http://clang.llvm.org/doxygen/group__CINDEX__CURSOR__TRAVERSAL.html). 

When I get CXCursors whose kind is CXCursor_ClassDecl, clang_getCursorSpelling() gives me the raw name (eg: if class is A, I get « A » ).
However when I get CXCursors whose kind is CXCursor_CXXBaseSpecifier, clang_getCursorSpelling() gives me a long name: « class A » instead of what I would like: « A ».

If there a way to access the raw class name for C++ parent classes? Or is the only possible way cutting the string to drop the « class » prefix?

Thank you very much for your help!
Lucas



More information about the cfe-users mailing list