diff --git a/index_tests/macros/complex.cc b/index_tests/macros/complex.cc index 080e247f..c943f2c6 100644 --- a/index_tests/macros/complex.cc +++ b/index_tests/macros/complex.cc @@ -44,7 +44,7 @@ OUTPUT: "bases": [], "derived": [], "vars": [], - "uses": ["12:5-12:10|0|1|16420"], + "uses": ["12:5-12:10|0|1|16420", "12:5-12:10|0|1|64|0"], "callees": [] }], "usr2type": [{ @@ -73,7 +73,7 @@ OUTPUT: "spell": "9:11-9:16|0|1|2", "extent": "9:1-9:20|0|1|0", "type": 53, - "uses": ["12:14-12:19|0|1|12"], + "uses": ["12:14-12:19|0|1|12", "12:14-12:19|0|1|64|0"], "kind": 13, "storage": 0 }, { diff --git a/index_tests/macros/foo.cc b/index_tests/macros/foo.cc index 7e5f159d..7a832595 100644 --- a/index_tests/macros/foo.cc +++ b/index_tests/macros/foo.cc @@ -59,7 +59,7 @@ OUTPUT: "funcs": [13788753348312146871], "vars": [], "instances": [], - "uses": ["5:12-5:15|0|1|4"] + "uses": ["5:12-5:15|0|1|4", "5:12-5:15|0|1|64|0"] }], "usr2var": [{ "usr": 1569772797058982873, diff --git a/index_tests/namespaces/namespace_alias.cc b/index_tests/namespaces/namespace_alias.cc index 46f0983e..01e27631 100644 --- a/index_tests/namespaces/namespace_alias.cc +++ b/index_tests/namespaces/namespace_alias.cc @@ -58,7 +58,7 @@ OUTPUT: "declarations": ["1:11-1:14|0|1|1"], "alias_of": 0, "bases": [], - "derived": [], + "derived": [17805385787823406700], "types": [17805385787823406700], "funcs": [], "vars": [], @@ -87,7 +87,7 @@ OUTPUT: "kind": 3, "declarations": ["3:20-3:23|17805385787823406700|2|1025"], "alias_of": 0, - "bases": [], + "bases": [17805385787823406700, 17805385787823406700, 17805385787823406700, 17805385787823406700], "derived": [], "types": [], "funcs": [], @@ -105,8 +105,8 @@ OUTPUT: "kind": 3, "declarations": ["2:15-2:18|926793467007732869|2|1025"], "alias_of": 0, - "bases": [], - "derived": [], + "bases": [926793467007732869, 926793467007732869, 926793467007732869, 926793467007732869], + "derived": [14450849931009540802], "types": [14450849931009540802], "funcs": [], "vars": [], diff --git a/index_tests/usage/func_called_from_macro_argument.cc b/index_tests/usage/func_called_from_macro_argument.cc index 9ceebb33..c3bb78d8 100644 --- a/index_tests/usage/func_called_from_macro_argument.cc +++ b/index_tests/usage/func_called_from_macro_argument.cc @@ -22,7 +22,7 @@ OUTPUT: "bases": [], "derived": [], "vars": [], - "uses": ["6:14-6:20|0|1|16420"], + "uses": ["6:14-6:20|0|1|16420", "6:14-6:20|0|1|64|0"], "callees": [] }, { "usr": 11404881820527069090, diff --git a/src/indexer.h b/src/indexer.h index 99fbc921..146ff5b4 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -71,8 +71,6 @@ void Reflect(Writer& visitor, Reference& value); void Reflect(Reader& visitor, Use& value); void Reflect(Writer& visitor, Use& value); -MAKE_REFLECT_TYPE_PROXY2(clang::StorageClass, uint8_t); - template struct NameMixin { std::string_view Name(bool qualified) const { @@ -104,11 +102,12 @@ struct FuncDef : NameMixin { // Functions that this function calls. std::vector callees; + int file_id = -1; int16_t qual_name_offset = 0; int16_t short_name_offset = 0; int16_t short_name_size = 0; lsSymbolKind kind = lsSymbolKind::Unknown; - clang::StorageClass storage = clang::SC_None; + uint8_t storage = clang::SC_None; std::vector GetBases() const { return bases; } }; @@ -155,6 +154,7 @@ struct TypeDef : NameMixin { // type comes from a using or typedef statement). Usr alias_of = 0; + int file_id = -1; int16_t qual_name_offset = 0; int16_t short_name_offset = 0; int16_t short_name_size = 0; @@ -199,6 +199,7 @@ struct VarDef : NameMixin { // Type of the variable. Usr type = 0; + int file_id = -1; int16_t qual_name_offset = 0; int16_t short_name_offset = 0; int16_t short_name_size = 0; @@ -206,7 +207,7 @@ struct VarDef : NameMixin { lsSymbolKind kind = lsSymbolKind::Unknown; // Note a variable may have instances of both |None| and |Extern| // (declaration). - clang::StorageClass storage = clang::SC_None; + uint8_t storage = clang::SC_None; bool is_local() const { return spell && spell->kind != SymbolKind::File && diff --git a/src/message_handler.cc b/src/message_handler.cc index f6ef4695..a4be9c95 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -198,7 +198,7 @@ void EmitSemanticHighlighting(DB *db, std::string_view detailed_name; lsSymbolKind parent_kind = lsSymbolKind::Unknown; lsSymbolKind kind = lsSymbolKind::Unknown; - StorageClass storage = SC_None; + uint8_t storage = SC_None; // This switch statement also filters out symbols that are not highlighted. switch (sym.kind) { case SymbolKind::Func: { diff --git a/src/message_handler.h b/src/message_handler.h index f771ec0b..e4f79e78 100644 --- a/src/message_handler.h +++ b/src/message_handler.h @@ -63,7 +63,7 @@ struct Out_CclsPublishSemanticHighlighting int stableId = 0; lsSymbolKind parentKind; lsSymbolKind kind; - clang::StorageClass storage; + uint8_t storage; std::vector> ranges; // `lsRanges` is used to compute `ranges`. diff --git a/src/messages/ccls_callHierarchy.cc b/src/messages/ccls_callHierarchy.cc index 92267d83..97b753dd 100644 --- a/src/messages/ccls_callHierarchy.cc +++ b/src/messages/ccls_callHierarchy.cc @@ -114,7 +114,7 @@ bool Expand(MessageHandler* m, for (SymbolRef ref : def->callees) if (ref.kind == SymbolKind::Func) handle(Use{{ref.range, ref.usr, ref.kind, ref.role}, - def->spell->file_id}, + def->file_id}, call_type); } else { for (Use use : func.uses) diff --git a/src/query.cc b/src/query.cc index 927a54ab..ed11b8b4 100644 --- a/src/query.cc +++ b/src/query.cc @@ -158,7 +158,7 @@ QueryFile::DefUpdate BuildFileDefUpdate(const IndexFile& indexed) { template bool TryReplaceDef(llvm::SmallVectorImpl& def_list, Q&& def) { for (auto& def1 : def_list) - if (def1.spell->file_id == def.spell->file_id) { + if (def1.file_id == def.file_id) { def1 = std::move(def); return true; } @@ -182,7 +182,7 @@ IndexUpdate IndexUpdate::CreateDelta(IndexFile* previous, r.funcs_hint = int(current->usr2func.size() - previous->usr2func.size()); for (auto& it : previous->usr2func) { auto& func = it.second; - if (func.def.spell) + if (func.def.detailed_name[0]) r.funcs_removed.push_back(func.usr); r.funcs_declarations[func.usr].first = std::move(func.declarations); r.funcs_uses[func.usr].first = std::move(func.uses); @@ -190,7 +190,7 @@ IndexUpdate IndexUpdate::CreateDelta(IndexFile* previous, } for (auto& it : current->usr2func) { auto& func = it.second; - if (func.def.spell && func.def.detailed_name[0]) + if (func.def.detailed_name[0]) r.funcs_def_update.emplace_back(it.first, func.def); r.funcs_declarations[func.usr].second = std::move(func.declarations); r.funcs_uses[func.usr].second = std::move(func.uses); @@ -200,7 +200,7 @@ IndexUpdate IndexUpdate::CreateDelta(IndexFile* previous, r.types_hint = int(current->usr2type.size() - previous->usr2type.size()); for (auto& it : previous->usr2type) { auto& type = it.second; - if (type.def.spell) + if (type.def.detailed_name[0]) r.types_removed.push_back(type.usr); r.types_declarations[type.usr].first = std::move(type.declarations); r.types_uses[type.usr].first = std::move(type.uses); @@ -209,7 +209,7 @@ IndexUpdate IndexUpdate::CreateDelta(IndexFile* previous, }; for (auto& it : current->usr2type) { auto& type = it.second; - if (type.def.spell && type.def.detailed_name[0]) + if (type.def.detailed_name[0]) r.types_def_update.emplace_back(it.first, type.def); r.types_declarations[type.usr].second = std::move(type.declarations); r.types_uses[type.usr].second = std::move(type.uses); @@ -220,14 +220,14 @@ IndexUpdate IndexUpdate::CreateDelta(IndexFile* previous, r.vars_hint = int(current->usr2var.size() - previous->usr2var.size()); for (auto& it : previous->usr2var) { auto& var = it.second; - if (var.def.spell) + if (var.def.detailed_name[0]) r.vars_removed.push_back(var.usr); r.vars_declarations[var.usr].first = std::move(var.declarations); r.vars_uses[var.usr].first = std::move(var.uses); } for (auto& it : current->usr2var) { auto& var = it.second; - if (var.def.spell && var.def.detailed_name[0]) + if (var.def.detailed_name[0]) r.vars_def_update.emplace_back(it.first, var.def); r.vars_declarations[var.usr].second = std::move(var.declarations); r.vars_uses[var.usr].second = std::move(var.uses); @@ -246,7 +246,7 @@ void DB::RemoveUsrs(SymbolKind kind, if (!HasFunc(usr)) continue; QueryFunc& func = Func(usr); auto it = llvm::find_if(func.def, [=](const QueryFunc::Def& def) { - return def.spell->file_id == file_id; + return def.file_id == file_id; }); if (it != func.def.end()) func.def.erase(it); @@ -259,7 +259,7 @@ void DB::RemoveUsrs(SymbolKind kind, if (!HasType(usr)) continue; QueryType& type = Type(usr); auto it = llvm::find_if(type.def, [=](const QueryType::Def& def) { - return def.spell->file_id == file_id; + return def.file_id == file_id; }); if (it != type.def.end()) type.def.erase(it); @@ -272,7 +272,7 @@ void DB::RemoveUsrs(SymbolKind kind, if (!HasVar(usr)) continue; QueryVar& var = Var(usr); auto it = llvm::find_if(var.def, [=](const QueryVar::Def& def) { - return def.spell->file_id == file_id; + return def.file_id == file_id; }); if (it != var.def.end()) var.def.erase(it); @@ -400,6 +400,7 @@ void DB::Update(const Lid2file_id &lid2file_id, int file_id, for (auto &u : us) { auto& def = u.second; assert(def.detailed_name[0]); + u.second.file_id = file_id; AssignFileId(lid2file_id, file_id, def.spell); AssignFileId(lid2file_id, file_id, def.extent); AssignFileId(lid2file_id, file_id, def.callees); @@ -418,6 +419,7 @@ void DB::Update(const Lid2file_id &lid2file_id, int file_id, for (auto &u : us) { auto& def = u.second; assert(def.detailed_name[0]); + u.second.file_id = file_id; AssignFileId(lid2file_id, file_id, def.spell); AssignFileId(lid2file_id, file_id, def.extent); auto R = type_usr.try_emplace({u.first}, type_usr.size()); @@ -435,6 +437,7 @@ void DB::Update(const Lid2file_id &lid2file_id, int file_id, for (auto &u : us) { auto& def = u.second; assert(def.detailed_name[0]); + u.second.file_id = file_id; AssignFileId(lid2file_id, file_id, def.spell); AssignFileId(lid2file_id, file_id, def.extent); auto R = var_usr.try_emplace({u.first}, var_usr.size());