Use cursor extents for non-type template parameters

This commit is contained in:
Fangrui Song 2018-01-07 10:53:44 -08:00
parent 332a3b5240
commit ce6087978f

View File

@ -1072,7 +1072,11 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
if (ref_type.get_usr().size()) { if (ref_type.get_usr().size()) {
IndexType* ref_type_index = IndexType* ref_type_index =
db->Resolve(db->ToTypeId(ref_type.get_usr())); db->Resolve(db->ToTypeId(ref_type.get_usr()));
ref_type_index->uses.push_back(ref_cursor.get_spelling_range()); // The cursor extent includes `type name`, not just `name`. There
// seems no way to extract the spelling range of `type` and we do
// not want to do subtraction here.
// See https://github.com/jacobdufault/cquery/issues/252
ref_type_index->uses.push_back(ref_cursor.get_extent());
} }
} }
UniqueAdd(ref_index->uses, cursor.get_spelling_range()); UniqueAdd(ref_index->uses, cursor.get_spelling_range());