Quantcast

Getting CXIdxDeclInfo from CXIdxBaseClassInfo

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Getting CXIdxDeclInfo from CXIdxBaseClassInfo

Daniel Marjamäki via cfe-dev
Hi,

I am using the high-level API in clang-c, and using the
clang_indexSourceFile() to traverse the code. In the indexDeclaration
callback function, I can access the the CXIdxDeclInfo of the
declarations.

IndexerCallbacks cb{};
cb.indexDeclaration = [](CXClientData, const CXIdxDeclInfo *decl)
{
    if (auto class_ = ::clang_index_getCXXClassDeclInfo(decl))
    {
         // access class_->bases[i] as CIdxBaseClassInfo

My question is, given a CIdxBaseClassInfo pointer, how can I turn it
into CIdxDeclInfo and call clang_index_getCXXClassDeclInfo() again?

If the base class is not an instantiation of a template, it should be
visited by indexDeclaration() before. However template instantiated
classes are not visited (even if I pass
CXIndexOpt_IndexImplicitTemplateInstantiations to
clang_indexSourceFile(). I can't find a way to get a CXIdxDeclInfo
pointer to these template instantiated classes.

Attached is the test program I used. My goal is to get a pointer to
CXIdxDeclInfo to "RecursiveBase<Base>" and deduce the class hierarchy:

Derived -> RecursiveBase<Base> -> Base

Thanks in advance!

Nestal

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

test.cc (718 bytes) Download Attachment
Loading...