diff --git a/command_line.cc b/command_line.cc index 787ff256..3d07f3d9 100644 --- a/command_line.cc +++ b/command_line.cc @@ -604,7 +604,7 @@ void LanguageServerMain(std::string process_name) { -int mai232n(int argc, char** argv) { +int main(int argc, char** argv) { // We need to write to stdout in binary mode because in Windows, writing // \n will implicitly write \r\n. Language server API will ignore a // \r\r\n split request. diff --git a/indexer.cpp b/indexer.cpp index 06134196..845436fb 100644 --- a/indexer.cpp +++ b/indexer.cpp @@ -1,5 +1,7 @@ #include "indexer.h" +#include + #include "serializer.h" IndexedFile::IndexedFile(const std::string& path) @@ -555,9 +557,10 @@ optional AddDeclUsages(IndexedFile* db, clang::Cursor decl_cursor, return param.initial_type; } - void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { bool is_system_def = clang_Location_isInSystemHeader(clang_getCursorLocation(decl->cursor)); + if (is_system_def) + return; IndexParam* param = static_cast(client_data); IndexedFile* db = param->db; @@ -861,6 +864,10 @@ bool IsFunction(CXCursorKind kind) { } void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { + if (clang_Location_isInSystemHeader(clang_getCursorLocation(ref->cursor)) || + clang_Location_isInSystemHeader(clang_getCursorLocation(ref->referencedEntity->cursor))) + return; + IndexParam* param = static_cast(client_data); IndexedFile* db = param->db; clang::Cursor cursor(ref->cursor); @@ -1007,6 +1014,28 @@ void indexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* re } +void emptyIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {} +void emptyIndexEntityReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {} + +struct Timer { + using Clock = std::chrono::high_resolution_clock; + std::chrono::time_point start_; + + Timer() { + Reset(); + } + + void Reset() { + start_ = Clock::now(); + } + + void PrintElapsed() { + std::chrono::time_point end = Clock::now(); + + std::cerr << "Indexing took " << std::chrono::duration_cast(end - start_).count() << "ms" << std::endl; + } +}; + IndexedFile Parse(std::string filename, std::vector args, bool dump_ast) { clang::Index index(0 /*excludeDeclarationsFromPCH*/, 0 /*displayDiagnostics*/); clang::TranslationUnit tu(index, filename, args); @@ -1018,6 +1047,7 @@ IndexedFile Parse(std::string filename, std::vector args, bool dump IndexerCallbacks callbacks[] = { { &abortQuery, &diagnostic, &enteredMainFile, &ppIncludedFile, &importedASTFile, &startedTranslationUnit, &indexDeclaration, &indexEntityReference } + //{ &abortQuery, &diagnostic, &enteredMainFile, &ppIncludedFile, &importedASTFile, &startedTranslationUnit, &emptyIndexDeclaration, &emptyIndexEntityReference } /* callbacks.abortQuery = &abortQuery; callbacks.diagnostic = &diagnostic; @@ -1033,8 +1063,11 @@ IndexedFile Parse(std::string filename, std::vector args, bool dump IndexedFile db(filename); NamespaceHelper ns; IndexParam param(&db, &ns); + + Timer time; clang_indexTranslationUnit(index_action, ¶m, callbacks, sizeof(callbacks), CXIndexOpt_IndexFunctionLocalSymbols | CXIndexOpt_SkipParsedBodiesInSession, tu.cx_tu); + time.PrintElapsed(); clang_IndexAction_dispose(index_action); diff --git a/test.cc b/test.cc index 02d4fc80..63e643f9 100644 --- a/test.cc +++ b/test.cc @@ -82,7 +82,7 @@ void VerifySerializeToFrom(IndexedFile* file) { } } -int main(int argc, char** argv) { +int main23(int argc, char** argv) { // TODO: Assert that we need to be on clang >= 3.9.1 /* @@ -98,7 +98,7 @@ int main(int argc, char** argv) { //if (path != "tests/constructors/invalid_reference.cc") continue; //if (path == "tests/inheritance/class_inherit_templated_parent.cc") continue; //if (path != "tests/namespaces/namespace_reference.cc") continue; - if (path == "tests/stl.cc") continue; + //if (path != "tests/stl.cc") continue; //if (path != "tests/templates/template_class_type_usage_folded_into_one.cc") continue; //path = "C:/Users/jacob/Desktop/superindex/indexer/" + path;