Remove ResolveSpelling

This commit is contained in:
Fangrui Song 2017-12-31 23:34:00 -08:00
parent 02246a5c4b
commit cef47b13f7

View File

@ -44,11 +44,6 @@ Range Resolve(const CXSourceRange& range, CXFile* cx_file = nullptr) {
Position((int16_t)end_line, (int16_t)end_column) /*end*/); Position((int16_t)end_line, (int16_t)end_column) /*end*/);
} }
Range ResolveSpelling(const CXCursor& cx_cursor, CXFile* cx_file = nullptr) {
CXSourceRange cx_range = clang_Cursor_getSpellingNameRange(cx_cursor, 0, 0);
return Resolve(cx_range, cx_file);
}
Range ResolveExtent(const CXCursor& cx_cursor, CXFile* cx_file = nullptr) { Range ResolveExtent(const CXCursor& cx_cursor, CXFile* cx_file = nullptr) {
CXSourceRange cx_range = clang_getCursorExtent(cx_cursor); CXSourceRange cx_range = clang_getCursorExtent(cx_cursor);
return Resolve(cx_range, cx_file); return Resolve(cx_range, cx_file);
@ -1547,9 +1542,11 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
} }
default: default:
std::cerr << "!! Unhandled indexDeclaration: " std::cerr
<< ClangCursor(decl->cursor).ToString() << " at " << "!! Unhandled indexDeclaration: "
<< ResolveSpelling(decl->cursor).start.ToString() << std::endl; << ClangCursor(decl->cursor).ToString() << " at "
<< ClangCursor(decl->cursor).get_spelling_range().start.ToString()
<< std::endl;
std::cerr << " entityInfo->kind = " << decl->entityInfo->kind std::cerr << " entityInfo->kind = " << decl->entityInfo->kind
<< std::endl; << std::endl;
std::cerr << " entityInfo->USR = " << decl->entityInfo->USR std::cerr << " entityInfo->USR = " << decl->entityInfo->USR
@ -1653,7 +1650,8 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
// } // }
// TODO: search full history? // TODO: search full history?
Range loc = ResolveSpelling(ref->cursor); ClangCursor ref_cursor(ref->cursor);
Range loc = ref_cursor.get_spelling_range();
IndexFuncId called_id = db->ToFuncId(ref->referencedEntity->USR); IndexFuncId called_id = db->ToFuncId(ref->referencedEntity->USR);
IndexFunc* called = db->Resolve(called_id); IndexFunc* called = db->Resolve(called_id);
@ -1738,12 +1736,9 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
case CXIdxEntity_Union: case CXIdxEntity_Union:
case CXIdxEntity_Struct: case CXIdxEntity_Struct:
case CXIdxEntity_CXXClass: { case CXIdxEntity_CXXClass: {
ClangCursor referenced_cursor = ref->referencedEntity->cursor; ClangCursor ref_cursor = ref->referencedEntity->cursor;
referenced_cursor = ref_cursor = ref_cursor.template_specialization_to_template_definition();
referenced_cursor.template_specialization_to_template_definition(); IndexType* referenced = db->Resolve(db->ToTypeId(ref_cursor.get_usr()));
IndexTypeId referenced_id = db->ToTypeId(referenced_cursor.get_usr());
IndexType* referenced = db->Resolve(referenced_id);
// //
// The following will generate two TypeRefs to Foo, both located at the // The following will generate two TypeRefs to Foo, both located at the
@ -1760,13 +1755,13 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
// Foo f; // Foo f;
// } // }
// //
UniqueAdd(referenced->uses, ResolveSpelling(ref->cursor)); UniqueAdd(referenced->uses, ref_cursor.get_spelling_range());
break; break;
} }
default: default:
std::cerr << "!! Unhandled indexEntityReference: " << cursor.ToString() std::cerr << "!! Unhandled indexEntityReference: " << cursor.ToString()
<< " at " << ResolveSpelling(ref->cursor).start.ToString() << " at " << ClangCursor(ref->cursor).get_spelling_range().start.ToString()
<< std::endl; << std::endl;
std::cerr << " ref->referencedEntity->kind = " std::cerr << " ref->referencedEntity->kind = "
<< ref->referencedEntity->kind << std::endl; << ref->referencedEntity->kind << std::endl;
@ -1774,7 +1769,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
std::cerr << " ref->parentEntity->kind = " std::cerr << " ref->parentEntity->kind = "
<< ref->parentEntity->kind << std::endl; << ref->parentEntity->kind << std::endl;
std::cerr << " ref->loc = " std::cerr << " ref->loc = "
<< ResolveSpelling(ref->cursor).start.ToString() << std::endl; << ClangCursor(ref->cursor).get_spelling_range().start.ToString() << std::endl;
std::cerr << " ref->kind = " << ref->kind << std::endl; std::cerr << " ref->kind = " << ref->kind << std::endl;
if (ref->parentEntity) if (ref->parentEntity)
std::cerr << " parentEntity = " std::cerr << " parentEntity = "