Remove definition_spelling from uses in IndexVar

Instead, specify `include_decl = true` in GetUsesOfSymbol
This commit is contained in:
Fangrui Song 2018-01-26 17:51:33 -08:00
parent 37809def7c
commit 6b3673a438
2 changed files with 5 additions and 3 deletions

View File

@ -1432,8 +1432,8 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
var->def.definition_extent = decl_cursor.get_extent();
} else {
var->def.declaration = decl_spell;
UniqueAdd(var->uses, decl_spell);
}
UniqueAdd(var->uses, decl_spell);
AddDeclInitializerUsages(db, decl_cursor);
var = db->Resolve(var_id);
@ -1829,7 +1829,6 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
var->def.short_name = referenced.get_spelling();
SetVarDetail(var, referenced, nullptr, true, db, param);
var->def.kind = ClangSymbolKind::Parameter;
UniqueAdd(var->uses, referenced.get_spelling_range());
}
}
UniqueAdd(var->uses, loc);

View File

@ -202,7 +202,10 @@ std::vector<QueryLocation> GetUsesOfSymbol(QueryDatabase* db,
}
case SymbolKind::Var: {
QueryVar& var = db->vars[symbol.idx];
return var.uses;
std::vector<QueryLocation> ret = var.uses;
if (include_decl && var.def && var.def->definition_spelling)
ret.push_back(*var.def->definition_spelling);
return ret;
}
case SymbolKind::File:
case SymbolKind::Invalid: {