Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Add TemplateVisitor to handle CXCursor_OverloadedDeclRef in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Dec 24, 2017
1 parent 42ff979 commit c9d6f5c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/indexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,27 @@ std::string GetDocumentContentInRange(CXTranslationUnit cx_tu,
return result;
}

ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
ClangCursor parent,
void* client_data) {
switch (cursor.get_kind()) {
default:
cursor.VisitChildren(&TemplateVisitor, client_data);
/* fallthrough */
case CXCursor_FunctionTemplate:
case CXCursor_ClassTemplate:
return ClangCursor::VisitResult::Continue;
case CXCursor_OverloadedDeclRef: {
unsigned num_overloaded = clang_getNumOverloadedDecls(cursor.cx_cursor);
for (unsigned i = 0; i != num_overloaded; i++) {
// ClangCursor overloaded = clang_getOverloadedDecl(cursor.cx_cursor, i);
// TODO handle references
}
return ClangCursor::VisitResult::Continue;
}
}
}

} // namespace

// static
Expand Down Expand Up @@ -1255,6 +1276,14 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
}
}

// CXCursor_OverloadedDeclRef in templates are not processed by
// OnIndexReference, thus we use TemplateVisitor to collect function
// references.
if (decl->entityInfo->templateKind == CXIdxEntity_Template) {
// TODO put db and caller into client data
decl_cursor.VisitChildren(&TemplateVisitor, (void*)0);
}

// Add function usage information. We only want to do it once per
// definition/declaration. Do it on definition since there should only
// ever be one of those in the entire program.
Expand Down

0 comments on commit c9d6f5c

Please sign in to comment.