[cfe-dev] Getting CXIdxDeclInfo from CXIdxBaseClassInfo

Nestal Wan via cfe-dev cfe-dev at lists.llvm.org
Wed Mar 15 08:44:48 PDT 2017


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cc
Type: text/x-c++src
Size: 525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170315/4ae53d83/attachment.cc>


More information about the cfe-dev mailing list