From 1a4da727da918a6ae9817df4e3a2a8a595bb085b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 20 Feb 2018 20:26:17 -0800 Subject: [PATCH] Index namespace alias and MSVC __interface; add --enable-assert to waf; add lexical container to xref requests --- src/command_line.cc | 1 - src/config.h | 17 ++- src/indexer.cc | 97 ++++++-------- src/language_server_api.h | 2 +- src/messages/cquery_base.cc | 10 +- src/messages/cquery_callers.cc | 4 +- src/messages/cquery_derived.cc | 9 +- src/messages/cquery_random.cc | 6 +- src/messages/cquery_vars.cc | 4 +- src/messages/text_document_definition.cc | 24 ++-- src/messages/text_document_references.cc | 5 +- src/query_utils.cc | 157 +++++++++-------------- src/query_utils.h | 11 +- wscript | 14 +- 14 files changed, 156 insertions(+), 205 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index 12efb94b..5be17f38 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -23,7 +23,6 @@ #include "serializer.h" #include "serializers/json.h" #include "test.h" -#include "threaded_queue.h" #include "timer.h" #include "timestamp_manager.h" #include "work_thread.h" diff --git a/src/config.h b/src/config.h index ef5aa50a..f52ac86e 100644 --- a/src/config.h +++ b/src/config.h @@ -162,13 +162,13 @@ struct Config { }; Completion completion; - // Maximum number of definition/reference/... results. - int maxXrefResults = 500; - struct Extension { - // If true, reference results will include "containerName". - bool referenceContainer = false; + struct Xref { + // If true, |Location[]| response will include lexical container. + bool container = false; + // Maximum number of definition/reference/... results. + int maxNum = 300; }; - Extension extension; + Xref xref; struct Index { // 0: none, 1: doxygen, 2: all comments @@ -195,7 +195,7 @@ struct Config { }; MAKE_REFLECT_STRUCT(Config::ClientCapability, snippetSupport); MAKE_REFLECT_STRUCT(Config::Completion, filterAndSort, detailedLabel); -MAKE_REFLECT_STRUCT(Config::Extension, referenceContainer); +MAKE_REFLECT_STRUCT(Config::Xref, container, maxNum); MAKE_REFLECT_STRUCT(Config::Index, comments, attributeMakeCallsToCtor); MAKE_REFLECT_STRUCT(Config, compilationDatabaseCommand, @@ -233,8 +233,7 @@ MAKE_REFLECT_STRUCT(Config, client, completion, - maxXrefResults, - extension, + xref, index, dumpAST); diff --git a/src/indexer.cc b/src/indexer.cc index 9835d029..e10f9037 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1510,20 +1510,24 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { ClangCursor lex_parent(fromContainer(decl->lexicalContainer)); SetUsePreflight(db, sem_parent); SetUsePreflight(db, lex_parent); + ClangCursor cursor = decl->cursor; switch (decl->entityInfo->kind) { + case CXIdxEntity_Unexposed: + LOG_S(INFO) << "CXIdxEntity_Unexposed " << cursor.get_spell_name(); + break; + case CXIdxEntity_CXXNamespace: { - ClangCursor decl_cursor = decl->cursor; - Range spell = decl_cursor.get_spell(); + Range spell = cursor.get_spell(); IndexTypeId ns_id = db->ToTypeId(HashUsr(decl->entityInfo->USR)); IndexType* ns = db->Resolve(ns_id); ns->def.kind = GetSymbolKind(decl->entityInfo->kind); if (ns->def.detailed_name.empty()) { - SetTypeName(ns, decl_cursor, decl->semanticContainer, + SetTypeName(ns, cursor, decl->semanticContainer, decl->entityInfo->name, param); ns->def.spell = SetUse(db, spell, sem_parent, Role::Definition); ns->def.extent = - SetUse(db, decl_cursor.get_extent(), lex_parent, Role::None); + SetUse(db, cursor.get_extent(), lex_parent, Role::None); if (decl->semanticContainer) { IndexTypeId parent_id = db->ToTypeId( ClangCursor(decl->semanticContainer->cursor).get_usr_hash()); @@ -1537,6 +1541,10 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { break; } + case CXIdxEntity_CXXNamespaceAlias: + assert(false && "CXXNamespaceAlias"); + break; + case CXIdxEntity_ObjCProperty: case CXIdxEntity_ObjCIvar: case CXIdxEntity_EnumConstant: @@ -1804,6 +1812,7 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { case CXIdxEntity_Enum: case CXIdxEntity_Union: case CXIdxEntity_Struct: + case CXIdxEntity_CXXInterface: case CXIdxEntity_CXXClass: { ClangCursor decl_cursor = decl->cursor; Range spell = decl_cursor.get_spell(); @@ -1919,30 +1928,6 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { } break; } - - default: - std::cerr - << "!! Unhandled indexDeclaration: " - << ClangCursor(decl->cursor).ToString() << " at " - << ClangCursor(decl->cursor).get_spell().start.ToString() - << std::endl; - std::cerr << " entityInfo->kind = " << decl->entityInfo->kind - << std::endl; - std::cerr << " entityInfo->USR = " << decl->entityInfo->USR - << std::endl; - if (decl->declAsContainer) - std::cerr << " declAsContainer = " - << ClangCursor(decl->declAsContainer->cursor).ToString() - << std::endl; - if (decl->semanticContainer) - std::cerr << " semanticContainer = " - << ClangCursor(decl->semanticContainer->cursor).ToString() - << std::endl; - if (decl->lexicalContainer) - std::cerr << " lexicalContainer = " - << ClangCursor(decl->lexicalContainer->cursor).get_usr_hash() - << std::endl; - break; } } @@ -1990,17 +1975,38 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { ClangCursor cursor(ref->cursor); ClangCursor lex_parent(fromContainer(ref->container)); + ClangCursor referenced; + if (ref->referencedEntity) + referenced = ref->referencedEntity->cursor; SetUsePreflight(db, lex_parent); switch (ref->referencedEntity->kind) { - case CXIdxEntity_CXXNamespaceAlias: + case CXIdxEntity_Unexposed: + LOG_S(INFO) << "CXIdxEntity_Unexposed " << cursor.get_spell_name(); + break; + case CXIdxEntity_CXXNamespace: { - ClangCursor referenced = ref->referencedEntity->cursor; IndexType* ns = db->Resolve(db->ToTypeId(referenced.get_usr_hash())); AddUse(db, ns->uses, cursor.get_spell(), fromContainer(ref->container)); break; } + case CXIdxEntity_CXXNamespaceAlias: { + IndexType* ns = db->Resolve(db->ToTypeId(referenced.get_usr_hash())); + AddUse(db, ns->uses, cursor.get_spell(), fromContainer(ref->container)); + if (!ns->def.spell) { + ClangCursor sem_parent = referenced.get_semantic_parent(); + ClangCursor lex_parent = referenced.get_lexical_parent(); + SetUsePreflight(db, sem_parent); + SetUsePreflight(db, lex_parent); + ns->def.spell = SetUse(db, referenced.get_spell(), sem_parent, Role::Definition); + ns->def.extent = SetUse(db, referenced.get_extent(), lex_parent, Role::None); + std::string name = referenced.get_spell_name(); + SetTypeName(ns, referenced, nullptr, name.c_str(), param); + } + break; + } + case CXIdxEntity_ObjCProperty: case CXIdxEntity_ObjCIvar: case CXIdxEntity_EnumConstant: @@ -2146,6 +2152,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { case CXIdxEntity_ObjCProtocol: case CXIdxEntity_ObjCClass: case CXIdxEntity_Typedef: + case CXIdxEntity_CXXInterface: // MSVC __interface case CXIdxEntity_CXXTypeAlias: case CXIdxEntity_Enum: case CXIdxEntity_Union: @@ -2176,36 +2183,6 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { UniqueAddUseSpell(db, ref_type->uses, ref->cursor); break; } - - default: - std::cerr - << "!! Unhandled indexEntityReference: " << cursor.ToString() - << " at " - << ClangCursor(ref->cursor).get_spell().start.ToString() - << std::endl; - std::cerr << " ref->referencedEntity->kind = " - << ref->referencedEntity->kind << std::endl; - if (ref->parentEntity) - std::cerr << " ref->parentEntity->kind = " - << ref->parentEntity->kind << std::endl; - std::cerr - << " ref->loc = " - << ClangCursor(ref->cursor).get_spell().start.ToString() - << std::endl; - std::cerr << " ref->kind = " << ref->kind << std::endl; - if (ref->parentEntity) - std::cerr << " parentEntity = " - << ClangCursor(ref->parentEntity->cursor).ToString() - << std::endl; - if (ref->referencedEntity) - std::cerr << " referencedEntity = " - << ClangCursor(ref->referencedEntity->cursor).ToString() - << std::endl; - if (ref->container) - std::cerr << " container = " - << ClangCursor(ref->container->cursor).ToString() - << std::endl; - break; } } diff --git a/src/language_server_api.h b/src/language_server_api.h index ed98142c..80ab358c 100644 --- a/src/language_server_api.h +++ b/src/language_server_api.h @@ -638,6 +638,6 @@ MAKE_REFLECT_STRUCT(Out_CquerySetInactiveRegion, jsonrpc, method, params); struct Out_LocationList : public lsOutMessage { lsRequestId id; - std::vector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_LocationList, jsonrpc, id, result); diff --git a/src/messages/cquery_base.cc b/src/messages/cquery_base.cc index 2022d1a8..0b8d784a 100644 --- a/src/messages/cquery_base.cc +++ b/src/messages/cquery_base.cc @@ -27,13 +27,15 @@ struct CqueryBaseHandler : BaseMessageHandler { FindSymbolsAtLocation(working_file, file, request->params.position)) { if (sym.kind == SymbolKind::Type) { if (const auto* def = db->GetType(sym).AnyDef()) - out.result = GetLsLocations(db, working_files, - ToUses(db, def->parents), config->maxXrefResults); + out.result = + GetLsLocationExs(db, working_files, ToUses(db, def->parents), + config->xref.container, config->xref.maxNum); break; } else if (sym.kind == SymbolKind::Func) { if (const auto* def = db->GetFunc(sym).AnyDef()) - out.result = GetLsLocations(db, working_files, ToUses(db, def->base), - config->maxXrefResults); + out.result = + GetLsLocationExs(db, working_files, ToUses(db, def->base), + config->xref.container, config->xref.maxNum); break; } } diff --git a/src/messages/cquery_callers.cc b/src/messages/cquery_callers.cc index a0dd2edf..b859eef4 100644 --- a/src/messages/cquery_callers.cc +++ b/src/messages/cquery_callers.cc @@ -32,7 +32,9 @@ struct CqueryCallersHandler : BaseMessageHandler { uses.push_back(func_ref); for (Use func_ref : GetCallersForAllDerivedFunctions(db, func)) uses.push_back(func_ref); - out.result = GetLsLocations(db, working_files, uses, config->maxXrefResults); + out.result = + GetLsLocationExs(db, working_files, uses, config->xref.container, + config->xref.maxNum); break; } } diff --git a/src/messages/cquery_derived.cc b/src/messages/cquery_derived.cc index f6f1a1d0..b67e916f 100644 --- a/src/messages/cquery_derived.cc +++ b/src/messages/cquery_derived.cc @@ -27,13 +27,14 @@ struct CqueryDerivedHandler : BaseMessageHandler { FindSymbolsAtLocation(working_file, file, request->params.position)) { if (sym.kind == SymbolKind::Type) { QueryType& type = db->GetType(sym); - out.result = GetLsLocations(db, working_files, ToUses(db, type.derived), - config->maxXrefResults); + out.result = + GetLsLocationExs(db, working_files, ToUses(db, type.derived), + config->xref.container, config->xref.maxNum); break; } else if (sym.kind == SymbolKind::Func) { QueryFunc& func = db->GetFunc(sym); - out.result = GetLsLocations(db, working_files, ToUses(db, func.derived), - config->maxXrefResults); + out.result = GetLsLocationExs(db, working_files, ToUses(db, func.derived), + config->xref.container, config->xref.maxNum); break; } } diff --git a/src/messages/cquery_random.cc b/src/messages/cquery_random.cc index 500538b0..56e1e4a0 100644 --- a/src/messages/cquery_random.cc +++ b/src/messages/cquery_random.cc @@ -101,7 +101,7 @@ struct CqueryRandomHandler : BaseMessageHandler { } std::vector x(n, 1), y; - for (int j = 0; j < 30; j++) { + for (int j = 0; j < 8; j++) { y.assign(n, kDamping); for (int i = 0; i < n; i++) for (auto& it : adj[i]) @@ -124,8 +124,8 @@ struct CqueryRandomHandler : BaseMessageHandler { Maybe use = GetDefinitionExtentOfSymbol(db, syms[i]); if (!use) continue; - optional ls_loc = GetLsLocation(db, working_files, *use); - if (ls_loc) + if (auto ls_loc = GetLsLocationEx(db, working_files, *use, + config->xref.container)) out.result.push_back(*ls_loc); break; } diff --git a/src/messages/cquery_vars.cc b/src/messages/cquery_vars.cc index 544d3890..99657fad 100644 --- a/src/messages/cquery_vars.cc +++ b/src/messages/cquery_vars.cc @@ -39,8 +39,8 @@ struct CqueryVarsHandler : BaseMessageHandler { case SymbolKind::Type: { QueryType& type = db->types[id.id]; out.result = - GetLsLocations(db, working_files, ToUses(db, type.instances), - config->maxXrefResults); + GetLsLocationExs(db, working_files, ToUses(db, type.instances), + config->xref.container, config->xref.maxNum); break; } } diff --git a/src/messages/text_document_definition.cc b/src/messages/text_document_definition.cc index 907013bf..b2d061f5 100644 --- a/src/messages/text_document_definition.cc +++ b/src/messages/text_document_definition.cc @@ -1,4 +1,3 @@ -#include "fuzzy_match.h" #include "lex_utils.h" #include "message_handler.h" #include "query_utils.h" @@ -21,18 +20,17 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDefinition); struct Out_TextDocumentDefinition : public lsOutMessage { lsRequestId id; - std::vector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDefinition, jsonrpc, id, result); std::vector GetGotoDefinitionTargets(QueryDatabase* db, SymbolRef sym) { switch (sym.kind) { - // Returns GetDeclarationsOfSymbolForGotoDefinition and - // variable type definition. case SymbolKind::Var: { std::vector ret = GetDeclarationsOfSymbolForGotoDefinition(db, sym); + // If there is no declaration, jump the its type. if (ret.empty()) { for (auto& def : db->GetVar(sym).def) if (def.type) { @@ -67,6 +65,7 @@ struct TextDocumentDefinitionHandler Out_TextDocumentDefinition out; out.id = request->id; + Maybe on_def; bool has_symbol = false; int target_line = request->params.position.line; int target_column = request->params.position.character; @@ -87,6 +86,7 @@ struct TextDocumentDefinitionHandler // If on a definition, clear |uses| to find declarations below. if (spell.file == file_id && spell.range.Contains(target_line, target_column)) { + on_def = spell; uses.clear(); return false; } @@ -99,10 +99,16 @@ struct TextDocumentDefinitionHandler return true; }); - if (uses.empty()) + if (uses.empty()) { + // The symbol has no definition or the cursor is on a definition. uses = GetGotoDefinitionTargets(db, sym); + // There is no declaration but the cursor is on a definition. + if (uses.empty() && on_def) + uses.push_back(*on_def); + } AddRange(&out.result, - GetLsLocations(db, working_files, uses, config->maxXrefResults)); + GetLsLocationExs(db, working_files, uses, config->xref.container, + config->xref.maxNum)); if (!out.result.empty()) break; } @@ -111,7 +117,7 @@ struct TextDocumentDefinitionHandler if (out.result.empty()) { for (const IndexInclude& include : file->def->includes) { if (include.line == target_line) { - lsLocation result; + lsLocationEx result; result.uri = lsDocumentUri::FromPath(include.resolved_path); out.result.push_back(result); has_symbol = true; @@ -154,8 +160,8 @@ struct TextDocumentDefinitionHandler if (best_i != -1) { Maybe use = GetDefinitionSpellingOfSymbol(db, db->symbols[best_i]); assert(use); - optional ls_loc = GetLsLocation(db, working_files, *use); - if (ls_loc) + if (auto ls_loc = GetLsLocationEx(db, working_files, *use, + config->xref.container)) out.result.push_back(*ls_loc); } } diff --git a/src/messages/text_document_references.cc b/src/messages/text_document_references.cc index 14c1c3ce..af693d39 100644 --- a/src/messages/text_document_references.cc +++ b/src/messages/text_document_references.cc @@ -56,9 +56,8 @@ struct TextDocumentReferencesHandler // Found symbol. Return references. EachUse(db, sym, request->params.context.includeDeclaration, [&](Use use) { - if (optional ls_loc = - GetLsLocationEx(db, working_files, use, - config->extension.referenceContainer)) + if (optional ls_loc = GetLsLocationEx( + db, working_files, use, config->xref.container)) out.result.push_back(*ls_loc); }); break; diff --git a/src/query_utils.cc b/src/query_utils.cc index 730e3c5d..a7d1b23a 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -6,6 +6,7 @@ #include #include +#include #include namespace { @@ -118,25 +119,25 @@ std::vector GetDeclarationsOfSymbolForGotoDefinition( bool HasCallersOnSelfOrBaseOrDerived(QueryDatabase* db, QueryFunc& root) { std::unordered_set seen; - std::queue queue; + std::stack stack; seen.insert(root.usr); - queue.push(&root); - while (!queue.empty()) { - QueryFunc& func = *queue.front(); - queue.pop(); + stack.push(&root); + while (!stack.empty()) { + QueryFunc& func = *stack.top(); + stack.pop(); if (!func.uses.empty()) return true; if (auto* def = func.AnyDef()) { EachDefinedEntity(db->funcs, def->base, [&](QueryFunc& func1) { if (!seen.count(func1.usr)) { seen.insert(func1.usr); - queue.push(&func1); + stack.push(&func1); } }); EachDefinedEntity(db->funcs, func.derived, [&](QueryFunc& func1) { if (!seen.count(func1.usr)) { seen.insert(func1.usr); - queue.push(&func1); + stack.push(&func1); } }); } @@ -147,22 +148,20 @@ bool HasCallersOnSelfOrBaseOrDerived(QueryDatabase* db, QueryFunc& root) { std::vector GetCallersForAllBaseFunctions(QueryDatabase* db, QueryFunc& root) { std::vector callers; - const QueryFunc::Def* def = root.AnyDef(); - if (!def) - return callers; - - std::queue queue; - EachDefinedEntity(db->funcs, def->base, [&](QueryFunc& func1) { - queue.push(&func1); - }); - while (!queue.empty()) { - QueryFunc& func = *queue.front(); - queue.pop(); - + std::unordered_set seen; + std::stack stack; + seen.insert(root.usr); + stack.push(&root); + while (!stack.empty()) { + QueryFunc& func = *stack.top(); + stack.pop(); AddRange(&callers, func.uses); - if (const QueryFunc::Def* def1 = func.AnyDef()) { - EachDefinedEntity(db->funcs, def1->base, [&](QueryFunc& func1) { - queue.push(&func1); + if (auto* def = func.AnyDef()) { + EachDefinedEntity(db->funcs, def->base, [&](QueryFunc& func1) { + if (!seen.count(func1.usr)) { + seen.insert(func1.usr); + stack.push(&func1); + } }); } } @@ -173,20 +172,20 @@ std::vector GetCallersForAllBaseFunctions(QueryDatabase* db, std::vector GetCallersForAllDerivedFunctions(QueryDatabase* db, QueryFunc& root) { std::vector callers; - - std::queue queue; - EachDefinedEntity(db->funcs, root.derived, [&](QueryFunc& func) { - queue.push(&func); - }); - - while (!queue.empty()) { - QueryFunc& func = *queue.front(); - queue.pop(); - - EachDefinedEntity(db->funcs, func.derived, [&](QueryFunc& func1) { - queue.push(&func1); - }); + std::unordered_set seen; + std::stack stack; + seen.insert(root.usr); + stack.push(&root); + while (!stack.empty()) { + QueryFunc& func = *stack.top(); + stack.pop(); AddRange(&callers, func.uses); + EachDefinedEntity(db->funcs, func.derived, [&](QueryFunc& func1) { + if (!seen.count(func1.usr)) { + seen.insert(func1.usr); + stack.push(&func1); + } + }); } return callers; @@ -198,12 +197,10 @@ optional GetLsPosition(WorkingFile* working_file, return lsPosition(position.line, position.column); int column = position.column; - optional start = - working_file->GetBufferPosFromIndexPos(position.line, &column, false); - if (!start) - return nullopt; - - return lsPosition(*start, column); + if (optional start = + working_file->GetBufferPosFromIndexPos(position.line, &column, false)) + return lsPosition(*start, column); + return nullopt; } optional GetLsRange(WorkingFile* working_file, const Range& location) { @@ -272,13 +269,13 @@ optional GetLsLocation(QueryDatabase* db, optional GetLsLocationEx(QueryDatabase* db, WorkingFiles* working_files, Use use, - bool extension) { + bool container) { optional ls_loc = GetLsLocation(db, working_files, use); if (!ls_loc) return nullopt; lsLocationEx ret; ret.lsLocation::operator=(*ls_loc); - if (extension) { + if (container) { EachEntityDef(db, use, [&](const auto& def) { ret.containerName = std::string_view(def.detailed_name); return false; @@ -287,17 +284,15 @@ optional GetLsLocationEx(QueryDatabase* db, return ret; } -std::vector GetLsLocations(QueryDatabase* db, - WorkingFiles* working_files, - const std::vector& uses, - int limit) { - std::vector ret; - for (Use use : uses) { - optional location = - GetLsLocation(db, working_files, use); - if (location) - ret.push_back(*location); - } +std::vector GetLsLocationExs(QueryDatabase* db, + WorkingFiles* working_files, + const std::vector& uses, + bool container, + int limit) { + std::vector ret; + for (Use use : uses) + if (auto loc = GetLsLocationEx(db, working_files, use, container)) + ret.push_back(*loc); std::sort(ret.begin(), ret.end()); ret.erase(std::unique(ret.begin(), ret.end()), ret.end()); if (ret.size() > limit) @@ -311,6 +306,8 @@ optional GetSymbolInfo(QueryDatabase* db, SymbolIdx sym, bool use_short_name) { switch (sym.kind) { + case SymbolKind::Invalid: + break; case SymbolKind::File: { QueryFile& file = db->GetFile(sym); if (!file.def) @@ -321,51 +318,19 @@ optional GetSymbolInfo(QueryDatabase* db, info.kind = lsSymbolKind::File; return info; } - case SymbolKind::Type: { - const QueryType::Def* def = db->GetType(sym).AnyDef(); - if (!def) - break; - + default: { lsSymbolInformation info; - if (use_short_name) - info.name = def->ShortName(); - else - info.name = def->detailed_name; - info.kind = def->kind; - if (def->detailed_name.c_str() != def->ShortName()) - info.containerName = def->detailed_name; + EachEntityDef(db, sym, [&](const auto& def) { + if (use_short_name) + info.name = def.ShortName(); + else + info.name = def.detailed_name; + info.kind = def.kind; + info.containerName = def.detailed_name; + return false; + }); return info; } - case SymbolKind::Func: { - const QueryFunc::Def* def = db->GetFunc(sym).AnyDef(); - if (!def) - break; - - lsSymbolInformation info; - if (use_short_name) - info.name = def->ShortName(); - else - info.name = def->detailed_name; - info.kind = def->kind; - info.containerName = def->detailed_name; - return info; - } - case SymbolKind::Var: { - const QueryVar::Def* def = db->GetVar(sym).AnyDef(); - if (!def) - break; - - lsSymbolInformation info; - if (use_short_name) - info.name = def->ShortName(); - else - info.name = def->detailed_name; - info.kind = def->kind; - info.containerName = def->detailed_name; - return info; - } - case SymbolKind::Invalid: - break; } return nullopt; diff --git a/src/query_utils.h b/src/query_utils.h index 4e6d5c24..66fe415b 100644 --- a/src/query_utils.h +++ b/src/query_utils.h @@ -41,11 +41,12 @@ optional GetLsLocation(QueryDatabase* db, optional GetLsLocationEx(QueryDatabase* db, WorkingFiles* working_files, Use use, - bool extension); -std::vector GetLsLocations(QueryDatabase* db, - WorkingFiles* working_files, - const std::vector& refs, - int limit); + bool container); +std::vector GetLsLocationExs(QueryDatabase* db, + WorkingFiles* working_files, + const std::vector& refs, + bool container, + int limit); // Returns a symbol. The symbol will have *NOT* have a location assigned. optional GetSymbolInfo(QueryDatabase* db, WorkingFiles* working_files, diff --git a/wscript b/wscript index 8eb0a1cf..6b3a5dfc 100644 --- a/wscript +++ b/wscript @@ -83,8 +83,7 @@ def patch_byte_in_libclang(filename, offset, old, new): def options(opt): opt.load('compiler_cxx') grp = opt.add_option_group('Configuration options related to use of clang from the system (not recommended)') - grp.add_option('--use-system-clang', dest='use_system_clang', default=False, action='store_true', - help='deprecated. Please specify --llvm-config, e.g. /usr/bin/llvm-config llvm-config-6.0') + grp.add_option('--enable-assert', action='store_true') grp.add_option('--use-clang-cxx', dest='use_clang_cxx', default=False, action='store_true', help='use clang C++ API') grp.add_option('--bundled-clang', dest='bundled_clang', default='5.0.1', @@ -188,6 +187,12 @@ def configure(ctx): if 'release' in ctx.options.variant: cxxflags.append('-O' if 'asan' in ctx.options.variant else '-O3') + if ctx.options.enable_assert is None: + if 'debug' in ctx.options.variant: + ctx.options.enable_assert = True + if not ctx.options.enable_assert: + ctx.define('NDEBUG', 1) + if ctx.env.CXX_NAME == 'clang' and 'debug' in ctx.options.variant: cxxflags.append('-fno-limit-debug-info') @@ -208,11 +213,6 @@ def configure(ctx): return 'lib' + lib return lib - # TODO remove - if ctx.options.use_system_clang: - print((('!' * 50)+'\n')*3) - print('--use-system-clang is deprecated. Please specify --llvm-config, e.g. /usr/bin/llvm-config llvm-config-6.0') - # Do not use bundled clang+llvm if ctx.options.llvm_config is not None or ctx.options.clang_prefix is not None: if ctx.options.llvm_config is not None: