From 0ada56ef3bb785b9b56eeebb70dff2aad60b3f39 Mon Sep 17 00:00:00 2001 From: zhangjunphy Date: Wed, 31 Mar 2021 14:33:18 +0800 Subject: [PATCH] Fix short_name_size when getNameAsString does not return a prefix (#784) --- src/indexer.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index d24e11e7..89d78959 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -534,15 +534,18 @@ public: // e.g. operator type-parameter-1 i = 0; def.short_name_offset = 0; - } else if (short_name.empty() || (i >= 2 && name[i - 2] == ':')) { - // Don't replace name with qualified name in ns::name Cls::*name - def.short_name_offset = i; + def.short_name_size = name.size(); } else { - name.replace(i, short_name.size(), qualified); - def.short_name_offset = i + qualified.size() - short_name.size(); + if (short_name.empty() || (i >= 2 && name[i - 2] == ':')) { + // Don't replace name with qualified name in ns::name Cls::*name + def.short_name_offset = i; + } else { + name.replace(i, short_name.size(), qualified); + def.short_name_offset = i + qualified.size() - short_name.size(); + } + // name may be empty while short_name is not. + def.short_name_size = name.empty() ? 0 : 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] == ')')