From e0c921f93c66cf751938e7d3a70eab60095b7a51 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 9 Nov 2019 13:27:09 -0800 Subject: [PATCH] indexer: fix getAdjustedDecl for explicit instantiations; fix incorrect short_offset_size=1 when name is empty Fix #516 --- src/indexer.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 662579847..426c2def3 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -357,7 +357,7 @@ const Decl *getAdjustedDecl(const Decl *d) { while (d) { if (auto *r = dyn_cast(d)) { if (auto *s = dyn_cast(r)) { - if (!s->getTypeAsWritten()) { + if (!s->isExplicitSpecialization()) { llvm::PointerUnion result = s->getSpecializedTemplateOrPartial(); @@ -533,7 +533,8 @@ class IndexDataConsumer : public index::IndexDataConsumer { name.replace(i, short_name.size(), qualified); def.short_name_offset = i + qualified.size() - short_name.size(); } - def.short_name_size = short_name.size(); + // name may be empty while short_name is not. + def.short_name_size = name.empty() ? 0 : short_name.size(); for (int paren = 0; i; i--) { // Skip parentheses in "(anon struct)::name" if (name[i - 1] == ')')