Better template specialization

This commit is contained in:
Fangrui Song 2018-01-28 23:05:51 -08:00
parent dc1c72ce30
commit b7ce3dd60a
2 changed files with 12 additions and 9 deletions

View File

@ -1701,14 +1701,6 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
switch (decl->entityInfo->templateKind) { switch (decl->entityInfo->templateKind) {
default: default:
break; break;
case CXIdxEntity_Template: {
TemplateVisitorData data;
data.db = db;
data.container = decl_cursor;
data.param = param;
decl_cursor.VisitChildren(&TemplateVisitor, &data);
break;
}
case CXIdxEntity_TemplateSpecialization: case CXIdxEntity_TemplateSpecialization:
case CXIdxEntity_TemplatePartialSpecialization: { case CXIdxEntity_TemplatePartialSpecialization: {
// TODO Use a different dimension // TODO Use a different dimension
@ -1733,6 +1725,14 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
} }
origin->derived.push_back(type_id); origin->derived.push_back(type_id);
type->def.parents.push_back(origin_id); type->def.parents.push_back(origin_id);
}
// fallthrough
case CXIdxEntity_Template: {
TemplateVisitorData data;
data.db = db;
data.container = decl_cursor;
data.param = param;
decl_cursor.VisitChildren(&TemplateVisitor, &data);
break; break;
} }
} }

View File

@ -187,7 +187,10 @@ std::vector<QueryLocation> GetUsesOfSymbol(QueryDatabase* db,
switch (symbol.kind) { switch (symbol.kind) {
case SymbolKind::Type: { case SymbolKind::Type: {
QueryType& type = db->types[symbol.idx]; QueryType& type = db->types[symbol.idx];
return type.uses; std::vector<QueryLocation> ret = type.uses;
if (include_decl && type.def)
ret.push_back(*type.def->definition_spelling);
return ret;
} }
case SymbolKind::Func: { case SymbolKind::Func: {
// TODO: the vector allocation could be avoided. // TODO: the vector allocation could be avoided.