From 4efb4dbf25a6325daf32417c43058496636d5cf1 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Mon, 8 May 2017 18:21:21 -0700 Subject: [PATCH] Make querydb import more robust to usr changes --- src/query.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/query.cc b/src/query.cc index 71259e96..32907fcc 100644 --- a/src/query.cc +++ b/src/query.cc @@ -694,6 +694,13 @@ void QueryDatabase::ImportOrUpdate(const std::vector& upda auto it = usr_to_symbol.find(def.usr); assert(it != usr_to_symbol.end()); + if (it->second.kind != SymbolKind::Type) { + std::cerr << "!! Import/update got symbol kind " << (int)(it->second.kind) << ", expected SymbolKind::Type for usr " << def.usr << std::endl; + continue; + } + + assert(it->second.idx >= 0 && it->second.idx < types.size()); + optional& existing = types[it->second.idx]; if (!existing) existing = QueryType(def.usr); @@ -716,6 +723,13 @@ void QueryDatabase::ImportOrUpdate(const std::vector& upda auto it = usr_to_symbol.find(def.usr); assert(it != usr_to_symbol.end()); + if (it->second.kind != SymbolKind::Func) { + std::cerr << "!! Import/update got symbol kind " << (int)(it->second.kind) << ", expected SymbolKind::Func for usr " << def.usr << std::endl; + continue; + } + + assert(it->second.idx >= 0 && it->second.idx < funcs.size()); + optional& existing = funcs[it->second.idx]; if (!existing) existing = QueryFunc(def.usr); @@ -738,6 +752,13 @@ void QueryDatabase::ImportOrUpdate(const std::vector& updat auto it = usr_to_symbol.find(def.usr); assert(it != usr_to_symbol.end()); + if (it->second.kind != SymbolKind::Var) { + std::cerr << "!! Import/update got symbol kind " << (int)(it->second.kind) << ", expected SymbolKind::Var for usr " << def.usr << std::endl; + continue; + } + + assert(it->second.idx >= 0 && it->second.idx < vars.size()); + optional& existing = vars[it->second.idx]; if (!existing) existing = QueryVar(def.usr); @@ -761,4 +782,4 @@ void QueryDatabase::UpdateDetailedNames(size_t* qualified_name_index, SymbolKind else { detailed_names[*qualified_name_index] = name; } -} \ No newline at end of file +}