SEXP R_clang_getOverloadedDecl(SEXP r_cursor, SEXP r_index) { SEXP r_ans = R_NilValue; CXCursor cursor = * GET_REF(r_cursor, CXCursor); unsigned int index = REAL(r_index)[0]; CXCursor ans; ans = clang_getOverloadedDecl(cursor, index); r_ans = R_makeCXCursor(ans) ; return(r_ans); }
CXChildVisitResult IndexerJob::indexVisitor(CXCursor cursor, CXCursor parent, CXClientData data) { IndexerJob *job = static_cast<IndexerJob*>(data); { MutexLocker lock(&job->mMutex); if (job->mAborted) return CXChildVisit_Break; } const LastCursorUpdater updater(job->mLastCursor, cursor); const CXCursorKind kind = clang_getCursorKind(cursor); const RTags::CursorType type = RTags::cursorType(kind); if (type == RTags::Other) return CXChildVisit_Recurse; bool blocked = false; Location loc = job->createLocation(cursor, &blocked); if (blocked) { return CXChildVisit_Continue; } else if (loc.isNull()) { return CXChildVisit_Recurse; } if (testLog(VerboseDebug)) { Log log(VerboseDebug); log << cursor; CXCursor ref = clang_getCursorReferenced(cursor); if (!clang_isInvalid(clang_getCursorKind(ref)) && !clang_equalCursors(ref, cursor)) { log << "refs" << ref; } } switch (type) { case RTags::Cursor: job->handleCursor(cursor, kind, loc); break; case RTags::Include: job->handleInclude(cursor, kind, loc); break; case RTags::Reference: switch (kind) { case CXCursor_OverloadedDeclRef: { const int count = clang_getNumOverloadedDecls(cursor); for (int i=0; i<count; ++i) { const CXCursor ref = clang_getOverloadedDecl(cursor, i); job->handleReference(cursor, kind, loc, ref, parent); } break; } case CXCursor_CXXDeleteExpr: job->handleReference(cursor, kind, loc, findDestructorForDelete(cursor), parent); break; default: job->handleReference(cursor, kind, loc, clang_getCursorReferenced(cursor), parent); break; } break; case RTags::Other: assert(0); break; } return CXChildVisit_Recurse; }
cursor cursor::getOverloadedDecl(unsigned idx) { return { clang_getOverloadedDecl(cur, idx) }; }
CXChildVisitResult ClangIndexer::indexVisitor(CXCursor cursor, CXCursor parent, CXClientData data) { ClangIndexer *indexer = static_cast<ClangIndexer*>(data); // error() << "indexVisitor" << cursor; // FILE *f = fopen("/tmp/clangindex.log", "a"); // String str; // Log(&str) << cursor; // fwrite(str.constData(), 1, str.size(), f); // fwrite("\n", 1, 1, f); // fclose(f); const LastCursorUpdater updater(indexer->mLastCursor, cursor); const CXCursorKind kind = clang_getCursorKind(cursor); const RTags::CursorType type = RTags::cursorType(kind); if (type == RTags::Other) return CXChildVisit_Recurse; bool blocked = false; Location loc = indexer->createLocation(cursor, &blocked); if (blocked) { // error() << "blocked" << cursor; ++indexer->mBlocked; return CXChildVisit_Continue; } else if (loc.isNull()) { // error() << "Got null" << cursor; return CXChildVisit_Recurse; } ++indexer->mAllowed; if (indexer->mLogFile) { String out; Log(&out) << cursor; fwrite(out.constData(), 1, out.size(), indexer->mLogFile); fwrite("\n", 1, 1, indexer->mLogFile); } if (testLog(VerboseDebug)) { Log log(VerboseDebug); log << cursor; CXCursor ref = clang_getCursorReferenced(cursor); if (!clang_isInvalid(clang_getCursorKind(ref)) && !clang_equalCursors(ref, cursor)) { log << "refs" << ref; } } switch (type) { case RTags::Cursor: indexer->handleCursor(cursor, kind, loc); break; case RTags::Include: indexer->handleInclude(cursor, kind, loc); break; case RTags::Reference: switch (kind) { case CXCursor_OverloadedDeclRef: { const int count = clang_getNumOverloadedDecls(cursor); for (int i=0; i<count; ++i) { const CXCursor ref = clang_getOverloadedDecl(cursor, i); indexer->handleReference(cursor, kind, loc, ref, parent); } break; } case CXCursor_CXXDeleteExpr: indexer->handleReference(cursor, kind, loc, findDestructorForDelete(cursor), parent); break; case CXCursor_CallExpr: { // uglehack, see rtags/tests/nestedClassConstructorCallUgleHack/ const CXCursor ref = clang_getCursorReferenced(cursor); if (clang_getCursorKind(ref) == CXCursor_Constructor && clang_getCursorKind(indexer->mLastCursor) == CXCursor_TypeRef && clang_getCursorKind(parent) != CXCursor_VarDecl) { loc = indexer->createLocation(indexer->mLastCursor); indexer->handleReference(indexer->mLastCursor, kind, loc, ref, parent); } else { indexer->handleReference(cursor, kind, loc, ref, parent); } break; } default: indexer->handleReference(cursor, kind, loc, clang_getCursorReferenced(cursor), parent); break; } break; case RTags::Other: assert(0); break; } return CXChildVisit_Recurse; }